0

我用来tweetstream gem从 Twitter Streaming API 获取示例推文:

TweetStream.configure do |config|
    config.username = 'my_username'
    config.password = 'my_password'
    config.auth_method = :basic
end

@client = TweetStream::Client.new

@client.sample do |status|
    puts "#{status.text}"
end

但是,此脚本将在大约 100 条推文后停止打印推文(脚本继续运行)。可能是什么问题呢?

4

1 回答 1

0

Twitter Search API 为事物设置了某些任意(从外部)限制,来自文档

GET statuses/:id/retweeted_by 显示转发状态的最多 100 个成员的用户对象。

从 gem,该方法的代码是:

# Returns a random sample of all public statuses. The default access level
# provides a small proportion of the Firehose. The "Gardenhose" access
# level provides a proportion more suitable for data mining and
# research applications that desire a larger proportion to be statistically
# significant sample.
def sample(query_parameters = {}, &block)
  start('statuses/sample', query_parameters, &block)
end

我检查了 API 文档,但没有看到“状态/样本”的条目,但是查看上面的条目,我假设您已经访问了 100 个状态/xxx。

另外,如果我错了,请纠正我,但我相信 Twitter 不再接受基本身份验证,您必须使用 OAuth 密钥。如果是这样,那么这意味着您未经身份验证,搜索 API 也会以其他方式限制您,请参阅https://dev.twitter.com/docs/rate-limiting

希望有帮助。


好的,我在那里犯了一个错误,当我本应该查看流式 API时,我正在查看搜索API (我很抱歉),但是我所说的某些事情可能是您的问题的原因所以我会留下它。Twitter 肯定已经远离了基本身份验证,所以我会先尝试解决这个问题,请参阅:

https://dev.twitter.com/docs/auth/oauth/faq

于 2012-01-04T07:38:23.470 回答