I have an issue with Phirehose. I have experience using the REST API, but I am new to Phirehose (hence this might be naivety on my part). I am trying to stream data from the streaming API.
I have tried entering my credentials in the example code - "phirehose-master/example/sample.php". However, when executing the script, the page appears to be loading, but none of the data is printed on the screen. Is this correct?
I am using the below code (I have removed credentials for privacy, however these were added and it still does not work).
Thanks in advance.
<?php
require_once('../lib/Phirehose.php');
require_once('../lib/OauthPhirehose.php');
/**
* Example of using Phirehose to display the 'sample' twitter stream.
*/
class SampleConsumer extends OauthPhirehose
{
/**
* Enqueue each status
*
* @param string $status
*/
public function enqueueStatus($status)
{
/*
* In this simple example, we will just display to STDOUT rather than enqueue.
* NOTE: You should NOT be processing tweets at this point in a real application, instead they should be being
* enqueued and processed asyncronously from the collection process.
*/
$data = json_decode($status, true);
if (is_array($data) && isset($data['user']['screen_name'])) {
print $data['user']['screen_name'] . ': ' . urldecode($data['text']) . "\n";
}
}
}
// The OAuth credentials you received when registering your app at Twitter
define("TWITTER_CONSUMER_KEY", "REMOVED");
define("TWITTER_CONSUMER_SECRET", "REMOVED");
// The OAuth data for the twitter account
define("OAUTH_TOKEN", "REMOVED");
define("OAUTH_SECRET", "REMOVED");
// Start streaming
$sc = new SampleConsumer(OAUTH_TOKEN, OAUTH_SECRET, Phirehose::METHOD_SAMPLE);
$sc->consume();