【发布时间】:2015-04-15 20:59:16
【问题描述】:
我正在从文本文件中提取推文并以定时间隔发布推文。当第一条推文发布时,一切都很好。当下一条推文发布时,我收到一条错误消息:
我有四把钥匙,但我可以随时更新它们或获得新的...这是我正在使用的代码:
require 'Twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "..."
config.consumer_secret = "..."
config.access_token = "..."
config.access_token_secret = "..."
end
def repeat_every(interval)
loop do
start_time = Time.now
yield
elapsed = Time.now - start_time
sleep([interval - elapsed, 0].max)
end
end
blog_post = []
tweet_img = []
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
repeat_every(81000){
post
}
【问题讨论】:
-
它说您缺少一个名为“status”的必需参数,您调查过吗?
-
是的,我不知道如何添加那个参数......或者为什么......它一开始正常发推文......加上推文的代码说我使用“client.update(”text“ )”以发推文。所以我认为这会起作用。 :\ @cantido
-
您知道如何添加该参数吗? @cantido
标签: ruby windows loops twitter status