Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/owlycode/streamingbird
A PHP client for the Twitter Streaming APIs inspired from Phirehose
https://github.com/owlycode/streamingbird
twitter twitter-streaming-api
Last synced: 22 days ago
JSON representation
A PHP client for the Twitter Streaming APIs inspired from Phirehose
- Host: GitHub
- URL: https://github.com/owlycode/streamingbird
- Owner: OwlyCode
- License: gpl-2.0
- Created: 2016-03-17T17:15:33.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-12T08:43:44.000Z (almost 7 years ago)
- Last Synced: 2024-11-18T09:53:12.262Z (about 2 months ago)
- Topics: twitter, twitter-streaming-api
- Language: PHP
- Size: 27.3 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
StreamingBird is an automatically tested, PSR-4 compliant client for Twitter's streaming API.
[![Build Status](https://travis-ci.org/OwlyCode/StreamingBird.svg?branch=master)](https://travis-ci.org/OwlyCode/StreamingBird)
How to install
--------------With composer : `composer require owlycode/streaming-bird`.
Example usage
-------------```php
use OwlyCode\StreamingBird\StreamReader;
use OwlyCode\StreamingBird\StreamingBird;// Change these with yours.
$oauthToken = 'my token';
$oauthSecret = 'secret';
$consumerKey = 'my key';
$consumerSecret = 'secret';$bird = new StreamingBird($consumerKey, $consumerSecret, $oauthToken, $oauthSecret);
$bird
->createStreamReader(StreamReader::METHOD_FILTER)
->setTrack(['hello', 'hola', 'bonjour']) // Fetch every tweet containing one of the following words
->consume(function ($tweet) { // Now we provide a callback to execute on every received tweet.
echo '------------------------' . "\n";
echo $tweet['text'] . "\n";
})
;```
Monitoring
----------StreamingBird comes with some statistics about the stream that you can access. At the moment
it is an early approach with few informations but it is meant to grow in the future.```php
$reader->consume(function ($tweet, $monitor) use ($output) {
echo '------------------------' . "\n";
echo $monitor->get('tweets') . "\n"; // The total number of received tweets
echo $monitor->get('idle_time') . "\n"; // Elapsed seconds between the last two tweets.
echo $monitor->get('max_idle_time') . "\n"; // The maximum idle time since the beginning.
echo $tweet['text'] . "\n";
});
```Running the tests
-----------------Simply run :
```bash
composer install
./bin/vendor/phpunit
```