python-tweepy与oauth -error代码301-无法获取用户名

时间:2013-06-03 18:29:32

标签: python twitter oauth tweepy

我是python的新手,并尝试制作一个程序,在特定用户的时间轴上播放推文 我对调试这个很无能为力。网上帮助不大。这看起来很简单,不确定为什么它不起作用。 任何帮助将不胜感激。我使用的是python 2.7.3

consumer_token = ''
consumer_secret = ''
access_token = ''
access_secret = ''

auth = tweepy.OAuthHandler(consumer_token,consumer_secret)
auth.set_access_token(access_token,access_secret)

api  = tweepy.API(auth)
print api.me().name
api.update_status('Hello -tweepy + oauth!')

我尝试过这篇文章的建议 Error using api.update_status method in tweepy using Oauth2

File "C:\Python27\tweet_fetch.py", line 22, in twitter_fetch
    print api.me().name
File "C:\Python27\Lib\tweepy-1.2\tweepy\api.py", line 303, in me
    raise TweepError('Failed to fetch username: %s' % e)
TweepError: Failed to fetch username: Twitter error response: status code = 301

1 个答案:

答案 0 :(得分:1)

这是Tweepy-1.2版本中的bug。只需升级到最新的(2.0)tweepy版本:

pip install tweepy --upgrade

pip uninstall tweepy
pip install tweepy

希望有所帮助。