【问题标题】:Traceback when updating status on twitter via Tweepy通过 Tweepy 在 Twitter 上更新状态时的回溯
【发布时间】:2015-04-16 03:11:43
【问题描述】:

我一直在尝试使用 tweepy 在 Twitter 上发布我的 Rpi 读数,但首先我想检查 tweepy 是否正常工作,但事实并非如此。

我正确安装了软件包,但是当我尝试运行一个简单的代码来发布内容时,我收到了一个错误(是的,我已经创建了一个应用程序并拥有 4 个凭据)。

我正在尝试运行的代码:

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 代码(添加我的凭据)

$ 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}]

该文件中的代码,您可以在其原始来源中找到它:Tweepy in GITHUB

有什么帮助/建议吗?

【问题讨论】:

    标签: python twitter tweepy


    【解决方案1】:

    update_status() 方法的第一个位置参数被解释为media_ids parameter。您需要明确命名 status 参数以避免这种情况:

    api.update_status(status=single_tweet)
    

    这是 Tweepy 中的 recent change,看起来他们的 documentation 尚未更新以反映这一点。

    该项目的不同签名是reported as a bug

    该错误已于 2015 年 8 月修复; Tweepy 3.5 或更高版本再次将第一个位置参数视为status 参数。

    【讨论】:

      猜你喜欢
      • 2014-08-27
      • 2010-11-03
      • 2013-07-17
      • 2016-11-08
      • 1970-01-01
      • 1970-01-01
      • 2015-10-23
      • 2018-01-22
      • 2016-12-26
      相关资源
      最近更新 更多