使用twitter gem获取所有转推

时间:2014-08-05 13:19:31

标签: ruby-on-rails ruby twitter

我想使用twitter gem获取原始推文的转推。如果我将原始状态ID提供给twitter api,我想获得所有转推。有没有办法用twitter gem做到这一点。我没有找到任何解决方案

1 个答案:

答案 0 :(得分:1)

您可以使用twitter gem。

将其添加到您的Gemfile中并运行bundle install

现在你需要初始化twitter rest client。

client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "YOUR_CONSUMER_KEY"
  config.consumer_secret     = "YOUR_CONSUMER_SECRET"
  config.access_token        = "YOUR_ACCESS_TOKEN"
  config.access_token_secret = "YOUR_ACCESS_SECRET"
end


# @param tweet [Integer, String, URI, Twitter::Tweet] A Tweet ID, URI, or object.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve.
# Must be less than or equal to 100.
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a 
# timeline will include a user object with only the author's numerical ID when set
# to true, 't' or 1.

retweets = client.retweets(original_tweet_id, options = {})

你可以 read more ,这里是API console proof(它会要求twitter身份验证显示数据)