tweepy未授权 - tweepy.error.TweepError:未经授权

时间:2013-10-23 14:22:36

标签: twitter twitter-oauth tweepy

当我尝试使用tweepy进行twitter身份验证时,我收到以下错误。

  File "/usr/local/lib/python2.7/dist-packages/tweepy/models.py", line 146, in followers
    return self._api.followers(user_id=self.id, **kargs)
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 197, in _call
    return method.execute()
  File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 173, in execute
    raise TweepError(error_msg, resp)
tweepy.error.TweepError: Not authorized.

我没有构建网络应用程序。因此,身份验证更简单。

consumer_key="----------"
consumer_secret="----------"
access_token="--------------"
access_token_secret="-----------------"

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

api.get_user('---').followers()

2 个答案:

答案 0 :(得分:10)

固定。特定用户有受保护的推文。因此,.followers()失败了。

答案 1 :(得分:3)

我有一个 for ,通过我的粉丝循环,以获得所有粉丝。我遇到了同样的错误。 我的解决方法是:

try:
    api.get_user('---').followers()
    ...
except tweepy.TweepError:
    print("Failed to run the command on that user, Skipping...")

虽然它让你想念一些用户。我的循环已成功完成并获得了约99%的粉丝。因此,用户可能很少有保护推文。

相关问题