the_t_test_1
the_t_test_1

Reputation: 1263

How to send co-ordinates with Tweepy and Python to Twitter status update

I'd like to use Python 2.7 and Tweepy to send a status update to Twitter with a message and some geo-coordinates. I have used Tweepy a lot and everything else works fine, but when I try to pass the coordinates I get an 'Invalid coordinates.' message... the co-ordinates themselves are integers from Bing's API.

See here for tweepy reqs: http://docs.tweepy.org/en/v3.5.0/api.html

Code I am doing:

latitude = 51.5118029
longitude = -0.1337666
tweet = "Some tweet!"
api.update_status(tweet, latitude, longitude)

I get:

raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{u'message': u'Invalid coordinates.', u'code': 3}]

Any help much appreciated!

Upvotes: 0

Views: 329

Answers (2)

Jonas
Jonas

Reputation: 4058

Try this:

api.update_status(tweet, lat=latitude, long=longitude)

Without the lat and long parameter names, tweepy thinks you are supplying in_reply_to_status_id. This is the actual method declaration:

API.update_status(status[, in_reply_to_status_id][, lat][, long][, source][, place_id])

Upvotes: 3

the_t_test_1
the_t_test_1

Reputation: 1263

Turns out (unsurprisingly) you need to declare what the lat/lng are, i.e.

api.update_status(tweet, lat = latitude, long = longitude)

Upvotes: 0

Related Questions