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); // print_r($data); $this->tweetCounter ++; $filePath = 'tweets/' . time() . '_' . $this->tweetCounter . '.tweet'; file_put_contents($filePath, $status); } } // Start streaming $sc = new SampleConsumer('username', 'password', Phirehose::METHOD_FILTER); /* * find out here: http://www.idfromuser.com/ * * example 1: 302605902 nyandarguard, 284899423 Eidsin, 189069893 newshorts */ $users = array("189069893", "14923310", "298717298", "63525170", "191618689", "27108506", "15085420", "14859090", "148559999", "19356301", "21313187", "238438353"); $sc->setFollow($users); $sc->consume();
<?php require_once '../lib/Phirehose.php'; /** * Example of using Phirehose to display the 'sample' twitter stream. */ class SampleConsumer extends Phirehose { /** * 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['lang'] . ': ' . $data['user']['screen_name'] . ': ' . urldecode($data['text']) . "\n"; } } } // Start streaming $sc = new SampleConsumer('username', 'password', Phirehose::METHOD_SAMPLE); //$sc = new SampleConsumer('username', 'password', Phirehose::METHOD_SAMPLE, Phirehose::FORMAT_JSON, 'en'); $sc->setLang('es'); $sc->consume();
<?php require_once('../lib/Phirehose.php'); /** * Example of using Phirehose to display the 'sample' twitter stream. */ class SampleConsumer extends Phirehose { /** * 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"; } } } // Start streaming $sc = new SampleConsumer('newshorts', 'GD_00bouer', Phirehose::METHOD_SAMPLE); $sc->consume();