【问题标题】:python-tweepy with oauth -error code 301-failed to fetch usernamepython-tweepy with oauth -error code 301-failed to fetch username
【发布时间】:2013-05-29 23:56:34
【问题描述】:

我是 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

【问题讨论】:

    标签: python twitter oauth tweepy


    【解决方案1】:

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

    pip install tweepy --upgrade
    

    pip uninstall tweepy
    pip install tweepy
    

    希望对您有所帮助。

    【讨论】:

    • 我没有安装 pip。但是,我手动下载了 tweepy 库并对其进行了更新。身份验证现在正在工作。非常感谢!
    猜你喜欢
    • 2019-06-23
    • 2018-01-28
    • 1970-01-01
    • 1970-01-01
    • 2017-08-02
    • 2020-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多