Skip to content
Newer
Older
100644 46 lines (40 sloc) 1.12 KB
f9dc1b6 @igorclark added example usage script
authored Nov 30, 2010
1 <?php
2 /*
3 * Define your Twitter keys & secrets.
4 * Get these from the "Settings" & "My Access Token" pages
5 * for your app via htp://dev.twitter.com/apps
6 * These must be defined before you include
7 * tusc code (below) or the init will fail.
8 */
9 define('TWITTER_CONSUMER_KEY', 'xxxxxxxxxxxxxxxxxx');
10 define('TWITTER_CONSUMER_SECRET', 'xxxxxxxxxxxxxxxxxx');
11 define('TWITTER_OAUTH_TOKEN', 'xxxxxxxxxxxxxxxxxx');
12 define('TWITTER_OAUTH_TOKEN_SECRET', 'xxxxxxxxxxxxxxxxxx');
13
14 /*
15 * Include tusc code
16 */
17 require_once("tusc/setup.inc.php");
18
19 /*
20 * Create our TwitterOAuth utility object & get signed stream URL
21 */
22 $oauthutil = new TwitterOAuthUtility(
23 TWITTER_CONSUMER_KEY,
24 TWITTER_CONSUMER_SECRET,
25 TWITTER_OAUTH_TOKEN,
26 TWITTER_OAUTH_TOKEN_SECRET
27 );
28
29 /*
30 * Use streaming API URL
31 */
32 define("TWITTER_STREAM_API_URL", "https://userstream.twitter.com/2/");
33 $oauthutil->setHost(TWITTER_STREAM_API_URL);
34
35 /*
36 * Construct OAuth-signed user stream URL
37 */
38 $stream_url = $oauthutil->getOAuthUrl("user", "GET");
39
40 /*
41 * Consume stream using our OAuth-signed URL
42 */
43 $oauthPhirehose = new UserstreamPhirehose($stream_url);
44 $oauthPhirehose->consume();
45 ?>
Something went wrong with that request. Please try again.