Twitter API - 发布时获取推文ID

时间:2017-03-08 12:40:45

标签: ruby-on-rails ruby-on-rails-4 twitter sttwitterapi

当我有时从API发布推文时,推文ID会在执行后发生变化。我正在使用Ruby的Twitter Gem

@client = Twitter::REST::Client.new do |config|
  config.consumer_key        = ENV['TWITTER_CONSUMER_KEY']
  config.consumer_secret     = ENV['TWITTER_CONSUMER_KEY_SECRET']
  config.access_token        = token
  config.access_token_secret = token_secret
end

post_result = @client.update_with_media(content, image_file)
post_permalink = post_result.id
post_result = post_result.to_json

我得到以下回复

{"created_at":"Wed Feb 08 11:13:49 +0000 2017","id":829287112583286784,"id_str":"829287112583286784","text":"You must agree that the Classic Coffee without Chicory tastes thousands times better #ClassicCoffeeBrews <link>"}

当我尝试访问推文时,我收到错误。

  

https://twitter.com/PebbleInWaters/status/8292871125832867842

手动浏览用户时间线我发现推文ID已更改为829287114386894848

  

https://twitter.com/PebbleInWaters/status/829287114386894848

知道如何纠正这些吗?

0 个答案:

没有答案