【问题标题】:How to add Ruby Twitter status parameter to update如何添加 Ruby Twitter 状态参数以进行更新
【发布时间】:2015-06-22 03:08:51
【问题描述】:

我收到一条错误消息,提示“缺少必需的参数:状态。Twitter::Error::Forbidden”如何将状态参数添加到“client.update()”?

如果我将“更新”替换为“状态”,我的推文将不会发布,并且我会收到一条错误消息,提示找不到具有该 ID 的状态。我的代码如下:

def post 
    client = Twitter::REST::Client.new do |config|
        config.consumer_key = "..."
        config.consumer_secret = "..."
        config.access_token = "..."
        config.access_token_secret = "..."
    end
  File.open("tweets.txt") do |line|
    line.each do |item|
      tweets = item
      puts tweets
      client.update("#{tweets}").to_s
      sleep((rand*1800 +900).to_i)
    end
  end
end

【问题讨论】:

  • 你用的gem是什么版本的?
  • Ruby 2.1.5 x64 for windows...我应该使用没有 x64 的 2.1.5 吗?或者可能是不同的版本? @马克西姆
  • 或者你的意思是 twitter gem 的版本? @马克西姆
  • 是的,我问的是 gem 版本。
  • gem 是 twitter-5.14.0 @Maxim

标签: ruby windows twitter parameters tweets


【解决方案1】:
File.open("tweets.txt") do |line|
  line.each_line do |item|
    tweets = item
    puts tweets
    client.update("#{tweets}")
    sleep((rand*1800 +900).to_i)
  end
end

【讨论】:

    猜你喜欢
    • 2011-08-12
    • 2011-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-13
    • 2016-03-12
    • 2012-01-11
    • 1970-01-01
    相关资源
    最近更新 更多