Traceback when updating status on twitter via Tweepy

 ̄綄美尐妖づ 提交于 2019-12-21 04:09:12

问题


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.

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).

The code I'm trying to run:

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"

I got this:

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

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

The code in that file, you can find it in its origial source: Tweepy in GITHUB

Any help/advice please?


回答1:


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)

This is a recent change in Tweepy and it looks like their documentation hasn't been updated yet to reflect this.

The different signature has been reported as a bug for the project.

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.



来源:https://stackoverflow.com/questions/28527352/traceback-when-updating-status-on-twitter-via-tweepy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!