Python 迁移到Twitter API版本1.1(?)
我对twitterapi很陌生。 我不知道这段代码有什么问题,根据tweepy文档,它应该可以正常工作:Python 迁移到Twitter API版本1.1(?),python,twitter,tweepy,Python,Twitter,Tweepy,我对twitterapi很陌生。 我不知道这段代码有什么问题,根据tweepy文档,它应该可以正常工作: import oauth, tweepy from time import sleep #stars is confident information username = "*******" password = "***********" auth = tweepy.BasicAuthHandler(username, password) api = tweepy.API(auth)
import oauth, tweepy
from time import sleep
#stars is confident information
username = "*******"
password = "***********"
auth = tweepy.BasicAuthHandler(username, password)
api = tweepy.API(auth)
api.update_status('hello from tweepy!')
终端向我展示了:
$ python py/twi.py
Traceback (most recent call last):
File "py/twi.py", line 11, in <module>
api.update_status('hello from tweepy!')
File "/usr/lib/python2.7/dist-packages/tweepy/binder.py", line 179, in _call
return method.execute()
File "/usr/lib/python2.7/dist-packages/tweepy/binder.py", line 162, in execute
raise TweepError(error_msg, resp)
tweepy.error.TweepError: [{'message': 'The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.', 'code': 68}]
$python py/twi.py
回溯(最近一次呼叫最后一次):
文件“py/twi.py”,第11行,在
api.update_status('hello from tweepy!')
文件“/usr/lib/python2.7/dist packages/tweepy/binder.py”,第179行,in\u call
返回方法execute()
文件“/usr/lib/python2.7/dist packages/tweepy/binder.py”,执行中的第162行
raise TweepError(错误消息,响应)
tweepy.error.TweepError:[{'message':'Twitter REST API v1不再处于活动状态。请迁移到API v1.1。https://dev.twitter.com/docs/api/1.1/overview.“,”代码“:68}]
请提供帮助。您应该直接从github安装
tweepy
:
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install
如果需要在pip的
requirements.txt
文件中列出此更改,可以替换
tweepy==2.0
与
-e git+https://github.com/tweepy/tweepy.git#egg=tweepy
您正在使用不再使用的Twitter API 1.0。您有没有在一段时间内更新tweepy?快速浏览一下github,它看起来已经更新了。我在terminal中编写了sudo-apt-get-install-python-tweepy
,没有什么新内容。没有更新的tweepy的文档:(如何修复此代码以使其对1.1版有效?