【问题标题】:How to send co-ordinates with Tweepy and Python to Twitter status update如何使用 Tweepy 和 Python 将坐标发送到 Twitter 状态更新
【发布时间】:2018-01-22 07:38:29
【问题描述】:

我想使用 Python 2.7 和 Tweepy 向 Twitter 发送状态更新,其中包含一条消息和一些地理坐标。我经常使用 Tweepy,其他一切正常,但是当我尝试传递坐标时,我得到一个“无效坐标”。消息...坐标本身是来自 Bing 的 API 的整数。

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}]

非常感谢任何帮助!

【问题讨论】:

    标签: python twitter geolocation tweepy


    【解决方案1】:

    试试这个:

    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])
    

    【讨论】:

      【解决方案2】:

      结果(不出所料)您需要声明 lat/lng 是什么,即

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

      【讨论】:

        猜你喜欢
        • 2017-07-28
        • 2021-10-27
        • 2015-10-23
        • 1970-01-01
        • 2013-07-17
        • 2010-11-01
        • 2018-07-14
        • 2015-04-16
        • 2012-07-02
        相关资源
        最近更新 更多