403 错误与 tweepy [英] 403 Error with tweepy

查看:48
本文介绍了403 错误与 tweepy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 tweepy 使用 Python 操作 twitter 帐户,但我似乎在第一个障碍上滑倒了.无论我尝试什么,我都会收到 403 错误,但没有具体细节.

I am trying to use tweepy to operate a twitter account using Python but I appear to have slipped at the the first hurdle. No matter what I try, I keep getting a 403 error with no specific details.

import tweepy

# Consumer keys and access tokens, used for OAuth
consumer_key = 'XXXXXXXXXXX'
consumer_secret = 'XXXXXXXXXXX'
access_token = 'XXXXXXXXXXXX'
access_token_secret = 'XXXXXXXXXXX'
 
 
# OAuth process, using the keys and tokens
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
 
# Creation of the actual interface, using authentication
api = tweepy.API(auth)
 
# Sample method, used to update a status
api.update_status('Hello')

(密钥已被屏蔽,但我向您保证它们与 Twitter 提供的完全一样)

(keys are blanked out, but I assure you they are exactly as twitter provides)

这是教程提供的基本代码,但是只返回

This is the basic code provided by the tutorial, but it only returns

Traceback (most recent call last):
  File "C:\Users\Sam\Documents\Python\TWEEPY\Tweepy.py", line 22, in <module>
    api.update_status('Hello')
  File "C:\Python34\lib\site-packages\python_twitter-2.1-py3.4.egg\tweepy\binder.py", line 153, in _call
    raise TweepError(error_msg)
tweepy.error.TweepError: Twitter error response: status code = 403

有人有什么想法吗?我不明白为什么我的请求被禁止.据我所知,这些钥匙不是假的.

Does anyone have any ideas? I can't see why I am forbidden from my request. The keys are not false as far as I can tell.

谢谢

推荐答案

本次讨论有点旧,但无论如何它可能适用于您.

This discussion is a bit old, but it might apply to you anyway.

他们基本上说 Tweepy 默认使用 HTTP,而 Twitter 要求他们的 API 连接通过 TLS/SSL 并建议使用 auth = tweepy.auth.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET, secure=True)

They basically say that Tweepy uses HTTP by default and Twitter requires their API connections to go through TLS/SSL and suggest using auth = tweepy.auth.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET, secure=True)

另外,其中一条评论提到了问题,因为他的时钟提前了 10 分钟.

Also, one of the comments mentions having problems because his clock was set 10 minutes ahead of time.

这篇关于403 错误与 tweepy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆