Error with twitter package by sixohsix and its solution

I was playing around with the code in 21 Recipes for Mining Twitter Recipes written by Matthew A. Russell and I ran into an error which looks like:

raise TwitterHTTPError(e, uri, self.format, arg_data)
twitter.api.TwitterHTTPError: Twitter sent status 404 for URL: 1/search.json using parameters:
raise TwitterHTTPError(e, uri, self.format, arg_data)twitter.api.TwitterHTTPError: Twitter sent status 404 for URL: 1/search.json using parameters:

Upon further investigation, i realized that there's nothing wrong with Russell's code,it appears that there is a small glitch with the twitter library by sixohsix.

The documented way of running a search using the library is:

twitter_search = twitter.Twitter(domain='')

The above will result in an error mentioned earlier. This is because the library joins all parameters while building the url.

Somehow, it assumes that api_version="1" will be used for all kinds of API calls.

But it doesn't work with search since there's no need to state the version number for search.

Therefore the solution would be :

twitter_search = twitter.Twitter(domain='',api_version='')

Do not type anything in the api_version and you will get twitter search working correctly.


Hope it helps.