【问题标题】:Twitter search API, how to filter by @username?Twitter搜索API,如何按@username过滤?
【发布时间】:2012-08-29 21:48:13
【问题描述】:

我使用的是 Twitter API atom 格式

http://search.twitter.com/search.atom?lang=en&q=some_hashtag

但它会向我返回来自所有人的带有“some_hashtag”标签的推文。我正在寻找一些过滤器来搜索仅来自一个用户的带有“some_hashtag”标签的所有推文,例如@this_one。

我在“twitter get search”文档中没有找到这个参数

【问题讨论】:

    标签: php twitter


    【解决方案1】:

    你必须给q一个额外的参数:from:

    例如,通过@VictimCommunity 检索标签some_hashtag 的推文:

    http://search.twitter.com/search.atom?lang=en&q=some_hashtag%20from:VictimCommunity
    

    doc 中有描述,但有点隐蔽。

    【讨论】:

      【解决方案2】:

      Twitter 不允许您搜索特定用户组的关键字。

      由于您只是“搜索”一个用户的推文,我建议您只需使用 include_entities 阅读用户时间线,然后使用 PHP 过滤结果:

      https://dev.twitter.com/docs/api/1/get/statuses/user_timeline?screen_name=this_one&include_entities=1
      

      现在使用 PHP 通读...

      foreach ($tweets as $tweet) 
      {
          if (in_array('hashtag', $tweet->entities->hashtags))
          {
              // go...
          }
      }
      

      编辑:虽然这仍然有效,但我建议查看answer above

      【讨论】:

        【解决方案3】:

        【讨论】:

          猜你喜欢
          • 2021-07-25
          • 2012-02-29
          • 2015-12-10
          • 1970-01-01
          • 2018-10-13
          • 2014-07-01
          • 1970-01-01
          • 2021-12-18
          • 2013-01-20
          相关资源
          最近更新 更多