skip to Main Content

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!

2

Answers


  1. Chosen as BEST ANSWER

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

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

  2. 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])
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search