我正在尝试使用 twitter-python 连接到 twitter 的 API,但我不断收到这个讨厌的 404 错误!
代码如下:
import sys
import twitter
def main():
api = twitter.Api()
statuses = api.GetPublicTimeline()
print [s.user.name for s in statuses]
它应该返回在公共时间线上发布状态更新的人的姓名,但我得到了这个回溯。
Traceback (most recent call last):
File "new.py", line 14, in <module>
main()
File "new.py", line 10, in main
statuses = api.GetPublicTimeline()
File "/usr/lib/pymodules/python2.7/twitter.py", line 1319, in GetPublicTimeline
json = self._FetchUrl(url, parameters=parameters)
File "/usr/lib/pymodules/python2.7/twitter.py", line 2030, in _FetchUrl
url_data = opener.open(url, encoded_post_data).read()
File "/usr/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found
如果我尝试进行身份验证,我的所有请求都会返回 401。
谢谢你的帮助!