@@ -23,6 +23,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
- OpenSSL extension
24
24
25
25
26
+ Summary
27
+ -------
28
+
29
+ Use Codebird to connect to the Twitter REST ** and Streaming API :sparkles : ** from your PHP code.
30
+ Codebird supports full 3-way OAuth as well as application-only auth.
31
+
32
+
26
33
Authentication
27
34
--------------
28
35
@@ -339,6 +346,57 @@ Please note that your OAuth consumer key and secret is shared within
339
346
multiple Codebird instances, while the OAuth request and access tokens with their
340
347
secrets are * not* shared.
341
348
349
+
350
+ Consuming the Twitter Streaming API
351
+ -----------------------------------
352
+
353
+ The Streaming APIs give developers low latency access to Twitter’s global stream of
354
+ Tweet data. A proper implementation of a streaming client will be pushed messages
355
+ indicating Tweets and other events have occurred, without any of the overhead
356
+ associated with polling a REST endpoint.
357
+
358
+ To consume one of the available Twitter streams, follow these ** two steps:**
359
+
360
+ ``` php
361
+ // First, create a callback function:
362
+
363
+ function some_callback($message)
364
+ {
365
+ // gets called for every new streamed message
366
+
367
+ print_r($message);
368
+ flush();
369
+
370
+ // return false to continue streaming
371
+ // return true to close the stream
372
+
373
+ // close streaming after 1 minute for this sample
374
+ if (false /* some condition to close the stream */) {
375
+ return true;
376
+ }
377
+
378
+ return false;
379
+ }
380
+
381
+ // set the streaming callback in Codebird
382
+ $cb->setStreamingCallback('some_callback');
383
+
384
+ // any callable is accepted:
385
+ // $cb->setStreamingCallback(['MyClass', 'some_callback']);
386
+ ```
387
+
388
+ ``` php
389
+ // Second, start consuming the stream:
390
+ $reply = $cb->user();
391
+
392
+ // See the *Mapping API methods to Codebird function calls* section for method names.
393
+ // $reply = $cb->statuses_filter('track=Windows');
394
+ ```
395
+
396
+ Find more information on the [ Streaming API] ( https://dev.twitter.com/streaming/overview )
397
+ in the developer documentation website.
398
+
399
+
342
400
How Do I…?
343
401
----------
344
402
0 commit comments