Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Traceback when updating status on twitter via 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.

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?

like image 419
Thonka Avatar asked Feb 15 '15 14:02

Thonka


People also ask

How can I get more than 100 tweets on Tweepy?

If you need more than 100 Tweets, you have to use the paginator method and specify the limit i.e. the total number of Tweets that you want. Replace limit=1000 with the maximum number of tweets you want. Replace the limit=1000 with the maximum number of tweets you want (gist).

What is wait on rate limit Tweepy?

But keep in mind that Twitter levies a rate limit on the number of requests made to the Twitter API. To be precise, 900 requests/15 minutes are allowed; Twitter feeds anything above that an error.

How many tweets can Tweepy extract?

Tweepy provides the convenient Cursor interface to iterate through different types of objects. Twitter allows a maximum of 3200 tweets for extraction.


1 Answers

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.

like image 127
Martijn Pieters Avatar answered Oct 12 '22 21:10

Martijn Pieters