1. Go to this page and download the library: Download owlycode/streaming-bird library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
owlycode / streaming-bird example snippets
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";
})
;
$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";
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.