迁移到Twitter API版本1.1(?)

时间:2013-07-07 15:04:19

标签: python twitter tweepy

我对Twitter API很新。 我不知道这个代码有什么问题,根据tweepy文档应该可以正常工作:

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}]

请帮忙。

2 个答案:

答案 0 :(得分:2)

您应该直接从github安装tweepy

git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install

答案 1 :(得分:0)

如果您需要在pip的requirements.txt文件中列出此更改,则可以替换

tweepy==2.0

-e git+https://github.com/tweepy/tweepy.git#egg=tweepy

相关问题