我想使用 Python 2.7 和 Tweepy 向 Twitter 发送状态更新,其中包含消息和一些地理坐标。我已经使用了很多Tweepy,其他一切正常,但是当我尝试传递坐标时,我收到"无效坐标"消息...坐标本身是来自必应 API 的整数。
请参阅此处以获取tweepy reps:http://docs.tweepy.org/en/v3.5.0/api.html
我正在做的代码:
latitude = 51.5118029
longitude = -0.1337666
tweet = "Some tweet!"
api.update_status(tweet, latitude, longitude)
我得到:
raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{u'message': u'Invalid coordinates.', u'code': 3}]
任何帮助非常感谢!
试试这个:
api.update_status(tweet, lat=latitude, long=longitude)
如果没有lat
和long
参数名称,tweepy 认为您正在提供in_reply_to_status_id
。这是实际的方法声明:
API.update_status(status[, in_reply_to_status_id][, lat][, long][, source][, place_id])
事实证明(不出所料(您需要声明纬度/液化天然气是什么,即
api.update_status(tweet, lat = latitude, long = longitude)