Every repository with this icon (
Every repository with this icon (
| Description: | API wrapper for Twitter and Twitter Search API's edit |
-
Not sure if this is an issue with Crack or with this lib, but every time I try to create a friendship, I get this error:
base.friendship_create('anyone') Crack::ParseError: Invalid JSON string
from /Library/Ruby/Gems/1.8/gems/crack-0.1.2/lib/crack/json.rb:14:in `parse' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/request.rb:73:in `parse' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/request.rb:48:in `make_friendly' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/request.rb:34:in `perform' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/request.rb:10:in `post' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/base.rb:162:in `perform_post' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/base.rb:76:in `friendship_create'Comments
-
Methods on Twitter class don't check for errors
0 comments Created 5 months ago by bkocikThe methods on the Twitter class (firehose, friend_ids, follower_ids, status, user) assume that no errors will occur, but all of them can at least return a 50x error. An example using FakeWeb:
>> FakeWeb.register_uri(:get, 'http://twitter.com/statuses/public_timeline.json', ?> :string => '{"request":"\/statuses\/public_timeline.json","error":"Bad gateway"}', ?> :status => ['502', 'Bad Gateway']) => [#["502", "Bad Gateway"], :string=>"{\"request\":\"\\/statuses\\/public_timeline.json\",\"error\":\"Bad gateway\"}"}, @method=:get, @uri="http://twitter.com/statuses/public_timeline.json", @times=1>] >> Twitter.firehose NoMethodError: undefined method `stringify_keys' for ["request", "/statuses/public_timeline.json"]:Array from /usr/lib/ruby/gems/1.8/gems/mash-0.0.3/lib/mash.rb:131:in `deep_update' from /usr/lib/ruby/gems/1.8/gems/mash-0.0.3/lib/mash.rb:50:in `initialize' from /usr/lib/ruby/gems/1.8/gems/twitter-0.6.11/lib/twitter.rb:34:in `new' from /usr/lib/ruby/gems/1.8/gems/twitter-0.6.11/lib/twitter.rb:34:in `firehose'Comments
-
Error handling 404 from Twitter::Search (JSON error)
0 comments Created 5 months ago by chubasWhen you request a search with a :since_id parameter too old, according to Twitter:
This method will return an HTTP 404 error if since_id is used and is too old to be in the search index
which results in a +Crack::ParseError+ exception
Comments
-
stringify_keys error in Mash.new when using Twitter::search
6 comments Created 5 months ago by metrostarhappens periodically, presumably when twitter search services returns a string for a response instead of a hash?
Comments
I had a similar issue on Ubuntu something was funny in Net::HTTP and was sending requests that twitter couldn't process (400 response). Here's what I put in my environment.rb to fix it:
module Twitter
class Searchdef fetch(force=false) if @fetch.nil? || force query = @query.dup query[:q] = query[:q].join(' ') query[:format] = 'json' #This line is the hack and whole reason we're monkey-patching at all. response = self.class.get('http://search.twitter.com/search', :query => query, :format => :json) @fetch = Mash.new(response) end @fetch endend end
labzero. Thanks a bunch. This worked for us! I tried doing a HTTP.new('search.twitter.com', nil).get('/search.json?q=obama') in irb and this would yield the same result. Your patch sidesteps that somehow. This problem just started occuring...I think after the ruby BigDecimal patch on EngineYard I believe, but that may be a coincidence. Any further insights?
Glad it worked for you! I have no idea why it's happening on my Ubuntu servers, they haven't changed and I just started using the twitter gem... The bug didn't happen locally on Leopard.
I've been experiencing this consistently with 2 apps hosted on Heroku. I'll try the patch.
UPDATE: Solved my problem on Heroku! Thanks!This is still acting up for me, even when I drop that code into my code. Still get the error randomly:
/var/lib/gems/1.8/gems/httparty-0.4.3/lib/httparty/response.rb:15:in
send': undefined methodstringify_keys' for #<String:0x7fe66b8cc4a0> (NoMethodError)from /var/lib/gems/1.8/gems/httparty-0.4.3/lib/httparty/response.rb:15:in `method_missing' from /var/lib/gems/1.8/gems/mash-0.0.3/lib/mash.rb:131:in `deep_update' from /var/lib/gems/1.8/gems/mash-0.0.3/lib/mash.rb:50:in `initialize' from pullterm.rb:63:in `new' from pullterm.rb:63:in `fetch' from /var/lib/gems/1.8/gems/twitter-0.6.14/lib/twitter/search.rb:109:in `each' from pullterm.rb:86:in `query_term' from pullterm.rb:127 -
A user-agent is required for twitter searches
0 comments Created 5 months ago by esilverbergI think this may be a new change to twitter, but user-agents are now required or else it will return a 400 Bad Request.
Add this line to work around it for now:
Twitter::Search.default_options = {:headers => {'User-Agent' => 'YOUR_USER_AGENT_STRING'}}Comments
-
Crack seems to have problem's with Twitter's JSON format. If I use the Rails json gem instead, I have no problems.
/Library/Ruby/Gems/1.8/gems/crack-0.1.1/lib/crack/json.rb:14:in `parse': Invalid JSON string (Crack::ParseError)
Comments
I am seeing this error as well (but i'm only using HTTParty, but assuming the issue is the same with the Twitter gem?), but it only seems to be on large data sets (like @barackobama's twitter friends):
/Library/Ruby/Gems/1.8/gems/crack-0.1.3/lib/crack/json.rb:14:in `parse': Invalid JSON string (Crack::ParseError)
Some of it 'seems' to be unicode issues potentially. I've had to write some stuff to get around the followers/tweets that blow it up, but I can't figure out which ones are causing it. Its always the same tweet/user however, which makes me think of some unicode issue causing improper JSON that blows up Crack.
-
title says it all. Mash redefines stringify_keys and stringify_keys! to have deep-stringify type functionality, but it should not be modifying Hash.
Can we avoid using (or patch) mash?
Comments











