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!
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])
结果(毫不奇怪),您需要声明纬度/经度,即
api.update_status(tweet, lat = latitude, long = longitude)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.