This file is indexed.

/usr/share/doc/php-horde-service-twitter/examples/twitter_browser.php is in php-horde-service-twitter 2.1.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
 * Callback page for Twitter integration.
 *
 * Copyright 2009-2013 Horde LLC (http://www.horde.org/)
 *
 * @author   Jan Schneider <jan@horde.org>
 * @author   Michael J. Rubinsky <mrubinsk@horde.org>
 * @license  http://www.horde.org/licenses/bsd BSD
 * @category Horde
 * @package  Service_Twitter
 */

require_once __DIR__ . '/../lib/base.php';

/* Keys - these are obtained when registering for the service */
$consumer_key = '********';
$consumer_secret = '*********';

/* Used to obtain an unprivileged request token */
$token_url = 'http://twitter.com/oauth/request_token';

/* Used for allowing the user to allow/deny access to the application */
// (User is redirected to this URL if needed).
$auth_url = 'http://twitter.com/oauth/authorize';

// Used to obtain an access token after user authorizes the application
$accessToken_url = 'http://twitter.com/oauth/access_token';

/* Parameters required for the Horde_Oauth_Consumer */
$params = array('key' => $consumer_key,
                'secret' => $consumer_secret,
                'requestTokenUrl' => $token_url,
                'authorizeTokenUrl' => $auth_url,
                'accessTokenUrl' => $accessToken_url,
                'signatureMethod' => new Horde_Oauth_SignatureMethod_HmacSha1());

/* Create the Consumer */
$oauth = new Horde_Oauth_Consumer($params);

/* Create the Twitter client */
$twitter = new Horde_Service_Twitter(array('oauth' => $oauth,
                                           'request' => new Horde_Controller_Request_Http()));
/* At this point we would check for an existing, valid authorization token */
// $auth_token should be a Horde_Oauth_Token object
// $auth_token = getTokenFromStorage();

// Do we have a good auth token? Keep in mind this is example code, and in a true
// callback page we probably wouldn't be doing anything if we already have a token,
// but for testing purposes....
if (!empty($auth_token)) {
    /* Have a token, tell the Twitter client about it */
    $twitter->auth->setToken($auth_token);

    // Do something cool....
    // $twitter->statuses->update('Testing Horde/Twitter integration');

} elseif (!empty($_SESSION['twitter_request_secret'])) {
    /* No existing auth token, maybe we are in the process of getting it? */
    $a_token = $twitter->auth->getAccessToken(new Horde_Controller_Request_Http(),
                                              $_SESSION['twitter_request_secret']);

    // Clear the request secret from the session now that we're done with it,
    // again, using _SESSION for simplicity for this example
    $_SESSION['twitter_request_secret'] = '';

    if ($a_token === false || empty($a_token)) {
        // We had a request secret, but something went wrong. maybe navigated
        // back here between requests?
        echo 'error';
        die;
    } else {
        // We have a good token, save it to DB etc....
        var_dump($a_token);
        die;
    }
}

// No auth token, not in the process of getting one...ask user to verify
$results = $twitter->auth->getRequestToken();
$_SESSION['twitter_request_secret'] = $results->secret;

// Redirect to auth url
Horde::externalUrl($twitter->auth->getUserAuthorizationUrl($results), false)->redirect();