如何获取指定用户或给定主题标签的所有推文?

时间:2011-06-24 10:44:41

标签: php xml json twitter

我正在尝试为用户'zapallpeople'获取所有推文的json / xml回调,或者包含'#zapallpeople'标签。 我已经尝试了搜索api,但它只返回过去6天的推文。 http://search.twitter.com/search.atom?q=from:zapallpeople%20OR%20%23zapallpeople

然后我尝试使用Phirehose PHP库使用Streaming API的跟踪方法执行此操作,但由于某种原因,这不适用于我们的Web服务器。 (我得到PHP超时错误)

<?php
require_once('../lib/Phirehose.php');
/**
 * Example of using Phirehose to display a live filtered stream using track words 
 */
class FilterTrackConsumer 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 FilterTrackConsumer('username', 'password', Phirehose::METHOD_FILTER);
$sc->setTrack(array('zapallpeople'));
$sc->consume();

还有其他方法吗?

1 个答案:

答案 0 :(得分:0)

我认为不再有历史了。请参阅google hits this link。它可能是一个古老的,但这个概念代表:不再有搜索历史了几天,据我所知,并没有完全由twitter指定。

相关问题