Note: This is beta software - Please read the following carefully before using: - http://code.google.com/p/phirehose/wiki/Introduction - http://dev.twitter.com/pages/streaming_api
Author: Fenn Bailey (fenn.bailey@gmail.com)
コード例 #1
0
ファイル: ghetto-queue-collect.php プロジェクト: dgw/ThinkUp
 /**
  * Overidden constructor to take class-specific parameters
  *
  * @param string $username
  * @param string $password
  * @param string $queueDir
  * @param integer $rotateInterval
  */
 public function __construct($username, $password, $queueDir = '/tmp', $rotateInterval = 10)
 {
     // Sanity check
     if ($rotateInterval < 5) {
         throw new Exception('Rotate interval set too low - Must be >= 5 seconds');
     }
     // Set subclass parameters
     $this->queueDir = $queueDir;
     $this->rotateInterval = $rotateInterval;
     // Call parent constructor
     return parent::__construct($username, $password, Phirehose::METHOD_FILTER);
 }
コード例 #2
0
 public function checkFilterPredicates()
 {
     $filename = \Swiftriver\Core\Setup::Configuration()->CachingDirectory . "/TwitterStreamingController.go";
     if (!\file_exists($filename)) {
         parent::disconnect();
     }
     $sec = (int) date('s');
     //this is called every 5 secs so to give us a break we ease off in the last 30 seconds of every minute
     if ($sec > 30) {
         return;
     }
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $queueFiles = glob($this->queueDir . '/phirehose-queue*.queue');
     $logger->log("Core::Modules::TwitterStreamingSearchClient Found " . count($queueFiles) . " queue files.", \PEAR_LOG_DEBUG);
     foreach ($queueFiles as $queueFile) {
         $this->processQueueFile($queueFile);
     }
 }
コード例 #3
0
 /**
  * Overidden constructor to take class-specific parameters
  * 
  * @param string $username
  * @param string $password
  * @param integer $filter_refresh_interval (defaults to 12 hours)
  */
 public function __construct($username, $password, $filter_refresh_interval = 43200)
 {
     // Get command line options/arguments
     $options = getopt("a:", array("url:"));
     // Define Wordpress AJAXURL from options
     $this->wp_ajax_url = $options['url'];
     // Get tracking terms
     $this->checkFilterPredicates();
     // Sanity check for filter update
     if ($filter_refresh_interval < 60 * 60) {
         // Filter refresh check set less than hourly:
         $filter_refresh_interval = 60 * 60 * 12;
         // Force to every 12 hours
     }
     $this->filterCheckMin = $filter_refresh_interval;
     // Set filter refresh rate
     // Call parent constructor
     return parent::__construct($username, $password, Phirehose::METHOD_FILTER);
 }
コード例 #4
0
 public function __construct($username, $password, $method = Phirehose::METHOD_SAMPLE, $format = self::FORMAT_JSON)
 {
     global $conf;
     self::$ex = $conf['consumer']['amqp_exchange_raw'];
     self::$qu = $conf['consumer']['amqp_queue_raw'];
     // Let's connect to AMQP too
     self::$mqconnection = new AMQPConnection($conf['amqp']['host'], $conf['amqp']['port'], $conf['amqp']['user'], $conf['amqp']['pass'], $conf['amqp']['vhost']);
     self::$mqchannel = self::$mqconnection->channel();
     $args = array();
     foreach ($conf['consumer']['amqp_queue_args'] as $amqpargs) {
         // echo $amqpargs."\n";
         $_args = split(',', $amqpargs);
         $args = array_merge($args, array($_args[0] => array($_args[1], $_args[2])));
     }
     print_r($args);
     // die();
     // queue_declare ( $queue="", $passive=false, $durable=false, $exclusive=false, $auto_delete=true, $nowait=false, $arguments=NULL, $ticket=NULL )
     self::$mqchannel->queue_declare(self::$qu, false, true, false, false, false, $args, NULL);
     self::$mqchannel->exchange_declare(self::$ex, 'topic', false, true, false);
     self::$mqchannel->queue_bind(self::$qu, self::$ex);
     $msg = new AMQPMessage("Connected to AMQP Broker, jusqu'ici, tout va bien", array('content_type' => 'text/plain'));
     self::$mqchannel->basic_publish($msg, self::$ex);
     parent::__construct($username, $password, $method = Phirehose::METHOD_SAMPLE, $format = self::FORMAT_JSON);
 }
コード例 #5
0
 public function __construct($username, $password, $method = UserstreamPhirehose::METHOD_USER, $format = self::FORMAT_JSON, $auth_method = UserstreamPhirehose::CONNECT_OAUTH)
 {
     parent::__construct($username, $password, $method, $format);
     $this->auth_method = $auth_method;
 }
コード例 #6
0
 /**
  * Subclass specific attribs
  */
 function DynamicTrackConsumer($username, $password, $method = Phirehose::METHOD_SAMPLE, $format = self::FORMAT_JSON)
 {
     parent::__construct($username, $password, $method, $format);
     $this->msgque = msg_get_queue(6367);
 }