【问题标题】:python-twitter: get_oauth( ) giving unexpected errorpython-twitter: get_oauth() 给出意外错误
【发布时间】:2013-11-02 09:55:00
【问题描述】:

我是 python 新手,我一直在编写代码来废弃 python 上的 twitter 数据。 以下是我的代码:

import csv
import json
import twitter_oauth
import sys
sys.path.append("/Users/jdschnieder/Documents/Modules")
print sys.path

#gain authorization to twitter
consumer_key = 'xdbX1g21REs0MPxofJPcFw'
consumer_secret = 'c9S9YI6G3GIdjkg67ecBaCXSJDlGw4sybTv1ccnkrA'
get_oauth_obj = twitter_oauth.GetOauth(consumer_key, consumer_secret)
get_oauth_obj.get_oauth()

错误发生在以下行:

 get_oauth_obj.get_oauth()

错误信息如下:

 ---------------------------------------------------------------------------
 Exception                                 Traceback (most recent call last)
 <ipython-input-36-5d124f99deb6> in <module>()
  --> 1 get_oauth_obj.get_oauth()

 /Users/jdschnieder/anaconda/python.app/Contents/lib/python2.7/site-packages/
 twitter_oauth-0.2.0-py2.7.egg/twitter_oauth.pyc in get_oauth(self)
    95         resp, content = client.request(_REQUEST_TOKEN_URL, "GET")
    96         if resp['status'] != '200':
 -> 97             raise Exception('Invalid response %s' % resp['status'])
    98 
    99         request_token = dict(self._parse_qsl(content))

 Exception: Invalid response 401

为什么会出现这个错误,有什么可能的解决方法?

谢谢,

【问题讨论】:

    标签: python oauth twitter-oauth python-twitter


    【解决方案1】:

    您使用的 Twitter 库似乎不支持 Twitter API v1.1。代替 twitter_oauth,使用列出的 Python 库之一here。例如,您可以使用 Tweepy,遵循 documentation for OAuth Authentication

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      • 2022-12-31
      • 2022-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多