I’m trying to write a simple twitter bot using python and tweepy. The code is as follows:
JavaScript
x
12
12
1
import tweepy
2
CONSUMER_KEY = 'xxxxxxxxxxxxxxxxx'
3
CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxx'
4
ACCESS_KEY = 'xxxxxxxxxxxxxxxxxxxxx'
5
ACCESS_SECRET = 'xxxxxxxxxxxxxxxxx'
6
7
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
8
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
9
api = tweepy.API(auth)
10
11
api.update_status('hi')
12
I get the following error:
JavaScript
1
2
1
TweepError: Twitter error response: status code = 400
2
I would like some info on how to avoid this error
Advertisement
Answer
This may be a bug that emerged in the 3.2.0 release of Tweepy. See this issue opened on GitHub. In that issue, TylerGlaiel notes that api.update_status fails if called thus:
JavaScript
1
2
1
api.update_status('Test')
2
But works if called like so:
JavaScript
1
2
1
api.update_status(status='Test')
2
I have also found this works. I imagine a fix will be out before long.