dongzhonggua4229 2011-06-24 10:44
浏览 61
已采纳

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

I'm trying to get a json/xml callback of all tweets for user 'zapallpeople' or containing hashtag '#zapallpeople'. I've tried the search api but it will only return tweets from the last 6 days. http://search.twitter.com/search.atom?q=from:zapallpeople%20OR%20%23zapallpeople

Then I've tried doing this with the Streaming API's tracking method using the Phirehose PHP library but this doesn't work on our webserver for some reason. (I get a PHP timeout error)

<?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']) . "
";
    }
  }
}

// Start streaming
$sc = new FilterTrackConsumer('username', 'password', Phirehose::METHOD_FILTER);
$sc->setTrack(array('zapallpeople'));
$sc->consume();

Are there any other methods to do this?

  • 写回答

1条回答 默认 最新

  • dongqing314511 2011-06-24 10:48
    关注

    I think there is no longer history available. See amongst other google hits this link. It might be an oldy, but the concept stands: there is no longer search history then a couple of days, not exactly specified by twitter as far as I know.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题