Ruby 版本:2.0.0-p0 Mac - Mountain Lion
以下是我的代码(tw_stream_track.rb):
require 'tweetstream'
TweetStream.configure do |config|
config.consumer_key = 'xxxxxxxxxxxxxxx'
config.consumer_secret = 'xxxxxxxxxxxxxxx'
config.oauth_token = 'xxxxxxxxxxxxxxx-xxxxxxxxxxxxxxx'
config.oauth_token_secret = 'xxxxxxxxxxxxxxx'
config.auth_method = :oauth
end
client = TweetStream::Client.new
client.on_error do |message|
puts message
end
client.track('apple', 'microsoft', 'samsung') do |status|
puts "#{status.text}"
end
当我从终端运行它时:
ruby tw_stream_track.rb
我得到以下信息:
/Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/tweetstream-2.5.0/lib/tweetstream/client.rb:436:in `block in connect': Failed to reconnect after 11 tries. (TweetStream::ReconnectError)
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/em-twitter-0.2.2/lib/em-twitter/connection.rb:296:in `call'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/em-twitter-0.2.2/lib/em-twitter/connection.rb:296:in `invoke_callback'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/em-twitter-0.2.2/lib/em-twitter/connection.rb:268:in `rescue in schedule_reconnect'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/em-twitter-0.2.2/lib/em-twitter/connection.rb:263:in `schedule_reconnect'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/em-twitter-0.2.2/lib/em-twitter/connection.rb:93:in `unbind'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/eventmachine-1.0.3/lib/eventmachine.rb:1440:in `event_callback'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/tweetstream-2.5.0/lib/tweetstream/client.rb:388:in `start'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/tweetstream-2.5.0/lib/tweetstream/client.rb:131:in `filter'
from /Users/mine/.rvm/gems/ruby-2.0.0-p0/gems/tweetstream-2.5.0/lib/tweetstream/client.rb:98:in `track'
这是我第一次使用 tweetstream,从文档来看,这似乎是我应该做的。我错过了什么?