【发布时间】:2014-01-18 19:19:57
【问题描述】:
我目前正在使用 Twitter API 来检索某些用户发布的推文。为了这个问题,我们以@justinbieber 为例。
当使用 https://stream.twitter.com/1.1/statuses/filter.json 资源时,将关注设置为所需的用户 ID (@justinbieber = 27260086),并允许它运行,虽然我只期望 @justinbieber 的推文,但我最终得到了发给他的推文他的数百万粉丝。显然,这意味着我获得的信息比我想要的要多得多,而且根据我的发现,我有时最终会错过用户自己的推文!
我已尝试更改https://dev.twitter.com/docs/streaming-apis/parameters 上的每个参数,但无济于事。
以下参数说明:
For each user specified, the stream will contain:
Tweets created by the user.
Tweets which are retweeted by the user.
Replies to any Tweet created by the user.
Retweets of any Tweet created by the user.
Manual replies, created without pressing a reply button (e.g. “@twitterapi I agree”).
因为它在文档中,我假设没有办法只获得该用户的推文而不必自己过滤结果(如前所述,这意味着我最终可能会错过用户自己的推文!) ,但我很想知道是否有人知道解决方法。
在有人建议使用诸如 statuses/user_timeline 之类的东西之前,我知道它能够做我想做的事,但是它有两个缺点让我一直使用流式 API:
- 每个请求都意味着我丢失了一个请求,而且由于 Twitter 是速率限制的,我想避免这种情况。
- 每个请求都有 HTTP 协议的昂贵开销。谈判花费了太多时间。
我想做的事可能吗? @justinbieber 只是高开销 Twitter 帐户的一个示例。我想使用此代码来检索许多高开销帐户的推文,因此速度和查看每个用户的每条推文的能力都是要求。
【问题讨论】:
标签: api twitter twitter-oauth twitter-streaming-api