tweepy 错误响应状态代码 400 [英] tweepy error response status code 400
本文介绍了tweepy 错误响应状态代码 400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 python 和 tweepy 编写一个简单的 Twitter 机器人.代码如下:
I'm trying to write a simple twitter bot using python and tweepy. The code is as follows:
import tweepy
CONSUMER_KEY = 'xxxxxxxxxxxxxxxxx'
CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxx'
ACCESS_KEY = 'xxxxxxxxxxxxxxxxxxxxx'
ACCESS_SECRET = 'xxxxxxxxxxxxxxxxx'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
api.update_status('hi')
我收到以下错误:
TweepError: Twitter error response: status code = 400
我想要一些有关如何避免此错误的信息
I would like some info on how to avoid this error
推荐答案
这可能是 Tweepy 3.2.0 版本中出现的错误.请参阅在 GitHub 上打开的此问题.在那个问题中,TylerGlaiel 指出如果这样调用 api.update_status 会失败:
This may be a bug that emerged in the 3.2.0 release of Tweepy. See this issue opened on GitHub. In that issue, TylerGlaiel notes that api.update_status fails if called thus:
api.update_status('Test')
但是如果这样调用就可以工作:
But works if called like so:
api.update_status(status='Test')
我也发现这有效.我想很快就会有一个修复程序.
I have also found this works. I imagine a fix will be out before long.
这篇关于tweepy 错误响应状态代码 400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文