问题
I am writing this program to get data from twitter of hashtags but it give me the error
import twitter
import json
import urllib
twitter_search = twitter.Twitter(domain="search.twitter.com")
for page in range(1,2):
k_results=twitter_search.search(q="jonson",rpp=100,page=page)
print json.dumps(k_results, sort_keys=True, indent=1)
errors are
Traceback (most recent call last):
File "<pyshell#6>", line 2, in <module>
k_results=twitter_search.search(q="Burma",rpp=100,page=page)
File "build\bdist.win32\egg\twitter\api.py", line 173, in __call__
return self._handle_response(req, uri, arg_data)
File "build\bdist.win32\egg\twitter\api.py", line 198, in _handle_response
raise TwitterHTTPError(e, uri, self.format, arg_data)
TwitterHTTPError: Twitter sent status 410 for URL: search.json using parameters: (q=Burma&rpp=100&page=1)
details: ヒ
回答1:
You try to use API 1.0 endpoint, http://search.twitter.com/search.format. It returns status 410, gone:
When
API v1is finally retired, all authenticated and unauthenticated requests toAPI v1will return aHTTP 410 Gonestatus. Older widgets will receive the same response. This status code signifies that allAPI v1-era resources are gone and not coming back.
Correct url for 1.1 search is https://api.twitter.com/1.1/search/tweets.json
I don't know whether twitter module you're using is updated to use API 1.1, and suggest to use one of modules that is.
来源:https://stackoverflow.com/questions/20359195/twitter-api-is-giving-error