Twitter api is giving error

半腔热情 提交于 2020-01-06 18:33:20

问题


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 v1 is finally retired, all authenticated and unauthenticated requests to API v1 will return a HTTP 410 Gone status. Older widgets will receive the same response. This status code signifies that all API 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!