Traceback when updating status on twitter via Twee

2019-03-25 15:52发布

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条回答
Bombasti
2楼-- · 2019-03-25 16:17

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.

查看更多
登录 后发表回答