2013-07-07 95 views
1

我對Twitter API相當陌生。 我不知道什麼是錯的這個代碼,它應該根據tweepy文檔工作確定:遷移到Twitter API版本1.1(?)

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

請幫助。

+1

您正在使用不再使用的Twitter API 1.0。 – user568109

+0

你在一段時間內更新了tweepy嗎?快速瀏覽一下github,看起來它已經更新了。 – Collin

+0

我在終端上寫了'sudo apt-get install python-tweepy',沒有什麼新東西。 –

回答

2

您應該從github上直接安裝tweepy

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

如果你需要列出一個requirements.txt文件PIP這種變化,可以更換

tweepy==2.0

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