【问题标题】:Getting all retweets with twitter gem使用 twitter gem 获取所有转推
【发布时间】:2014-08-05 21:33:13
【问题描述】:

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

【问题讨论】:

  • 你是如何获得原始推文 ID 的?

标签: ruby-on-rails ruby twitter


【解决方案1】:

您可以使用twitter gem。

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

现在你需要初始化 twitter rest 客户端。

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(它会要求推特验证显示数据)

【讨论】:

    猜你喜欢
    • 2015-06-28
    • 2015-06-27
    • 2017-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-03
    • 2015-05-15
    • 2016-12-18
    相关资源
    最近更新 更多