如何从 Facebook 聊天机器人获取用户的位置 api

How to get user's location from Facebook chatbot api

我想知道如何从 Facebook Messenger 聊天机器人获取用户的位置。我想要完成的是以下内容:聊天机器人会说类似 "Please send me your location" 的内容,然后用户会在 Facebook Messenger 应用程序上点击 "Share Location"。我已经弄清楚如何获取用户发送的文本消息,而不是位置。提前致谢!

可以获取位置和文本。更准确地说,如照片。 你需要 message.attachments.payload.coordinates。您也可以查看 message.attachments.type.

示例:

{
   "object": "page",
   "entry": [{
       "id": "1719442148306048",
       "time": 1466780344978,
       "messaging": [{
           "sender": {"id": "123456789"},
           "recipient": {"id": "987654321"},
           "timestamp": 1466780344847,
           "message": {
               "mid": "mid.12345698875:c80066d69b6cee1779",
               "seq": 65,
               "attachments": [{
                   "title": "Dmitry's Location",
                   "url": "Link to bing.com through facebook redirect"
                   "type": "location",
                   "payload": {"coordinates": {"lat": 55, "long": 37}}
               }]
           }
       }]
   }]
}