【发布时间】:2011-06-24 10:44:41
【问题描述】:
我正在尝试获取用户“zapallpeople”或包含标签“#zapallpeople”的所有推文的 json/xml 回调。 我已经尝试过搜索 api,但它只会返回过去 6 天的推文。 http://search.twitter.com/search.atom?q=from:zapallpeople%20OR%20%23zapallpeople
然后我尝试使用 Phirehose PHP 库通过 Streaming API 的跟踪方法执行此操作,但由于某种原因这在我们的网络服务器上不起作用。 (我收到一个 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();
还有其他方法可以做到这一点吗?
【问题讨论】: