I'm trying to get YAJL working in my app - been testing it off the Twitter API and the Digg API and I can't seem to get it working.
I'm not sure where I'm going wrong. Tapping into the Twitter streaming API using this code: (username/password removed)
max_allowed_errors = 1200
consecutive_errors = 0
while consecutive_errors < max_allowed_errors do
url = URI.parse("https://[username]:[password]!@stream.twitter.com/1/statuses/sample.json")
begin
Yajl::HttpStream.get(url) do |status|
consecutive_errors = 0
# puts status.inspect
end
rescue Yajl::HttpStream::InvalidContentType
consecutive_errors += 1
end
sleep(0.25*consecutive_errors)
end
I get an error:
Yajl::HttpStream::HttpError in DashboardsController#streamit
Code 200 expected got 0
The error refers to this line:
Yajl::HttpStream.get(url) do |status|
I'd like to avoid API-specific gems so I can reuse code and tap into other APIs down the road (i.e. TweetStream).
Thanks in advance for the help! Let me know if you have any questions or if I can clarify this at all.
Oh! I'll note I'm open to other gems to manage streaming if you have recommendations.