2017-08-14 21 views
0

我想使用Python 2.7和Tweepy向消息和一些地理座標發送狀態更新到Twitter。我已經使用Tweepy很多,其他一切正常,但是當我嘗試傳遞座標時,我得到一個「無效的座標」。消息......協調本身是Bing API的整數。如何發送與Tweepy和Python到Twitter狀態更新的協調

在這裏看到tweepy請求數: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}] 

任何幫助,非常感謝!

回答

0

原來(意料之中),你需要聲明緯度/經度是什麼,即

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

試試這個:

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

沒有latlong參數名稱,tweepy認爲你供應in_reply_to_status_id。這是實際的方法聲明:

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