通过 Tweepy 在 twitter 上更新状态时的回溯 [英] Traceback when updating status on twitter via Tweepy
问题描述
我一直在尝试使用 tweepy
在 Twitter 上发布我的 Rpi 读数,但首先我想检查 tweepy
是否正常工作,但事实并非如此.
I've been trying to post the readings from my Rpi on Twitter using tweepy
, but first I wanted to check if tweepy
was working properly, but it's not.
我正确安装了软件包,但是当我尝试运行一个简单的代码来发布某些内容时,出现错误(是的,我已经创建了一个应用程序并拥有 4 个凭据).
I installed the packages properly, but when I'm trying to run a simple code to post something, I got an error (Yes, I already created an app and have the 4 credentials).
我试图运行的代码:
import tweepy
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)
single_tweet = 'hello world'
api.update_status(single_tweet)
print "successfully Updated"
我明白了:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-armv6l/egg/tweepy/api.py", line 193, in update_status
File "build/bdist.linux-armv6l/egg/tweepy/binder.py", line 239, in _call
File "build/bdist.linux-armv6l/egg/tweepy/binder.py", line 223, in execute
tweepy.error.TweepError: [{u'message': u'media_ids parameter is invalid.', u'code': 44}]
我正在运行 tweepy 文件夹oauth.py"中的 python 代码(将其添加为我的凭据)
I'm runing the python code that is in the tweepy folder "oauth.py" (adding it my credentials)
$ sudo python oauth.py
RapiCARA
Traceback (most recent call last):
File "oauth.py", line 34, in <module>
api.update_status(' Hello world ')
File "build/bdist.linux-armv6l/egg/tweepy/api.py", line 193, in update_status
File "build/bdist.linux-armv6l/egg/tweepy/binder.py", line 239, in _call
File "build/bdist.linux-armv6l/egg/tweepy/binder.py", line 223, in execute
tweepy.error.TweepError: [{u'message': u'media_ids parameter is invalid.', u'code': 44}]
该文件中的代码,您可以在其原始来源中找到它:GITHUB 中的 Tweepy
The code in that file, you can find it in its origial source: Tweepy in GITHUB
有什么帮助/建议吗?
推荐答案
update_status()
方法的第一个位置参数被解释为 media_ids
参数.您需要明确命名您的 status
参数以避免这种情况:
The first positional argument to the update_status()
method is interpreted as the media_ids
parameter. You need to explicitly name your status
parameter to avoid this:
api.update_status(status=single_tweet)
这是 Tweepy 中的最近的变化,看起来像他们的文档 尚未更新以反映这一点.
This is a recent change in Tweepy and it looks like their documentation hasn't been updated yet to reflect this.
不同的签名已报告为项目的错误.
该错误已于 2015 年 8 月修复;3.5 或更高版本的 Tweepy 再次将第一个位置参数视为 status
参数.
The bug was fixed in August 2015; version 3.5 or newer of Tweepy once again treat the first positional argument as the status
parameter.
这篇关于通过 Tweepy 在 twitter 上更新状态时的回溯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!