有一种方法可以将我的位置从移动客户端发送到facebook-messenger,但我如何从机器人发送位置?(messenger platform api)
当我尝试从机器人发送一个类似的结构时,我得到了一个错误:(#100) Unsupported attachment 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}}
}]
}
}]
}]
}我尝试发送带有附件的邮件,如下所示:
"attachment": {
"type": "location",
"payload": {"coordinates": {"lat": 55, "long": 37}}
}发布于 2016-07-07 21:30:03
有一种解决方法。我们可以发送带有静态地图图像和url的通用模板到动态。对于谷歌原生地图应用,我们可以使用address http://maps.apple.com/maps (它使用相同的参数将所有非iOS用户重定向到iOS地图)。在安卓系统上,它可以打开谷歌地图应用。
{
"recipient": {"id": "132456"},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": {
"element": {
"title": "Your current location",
"image_url": "https:\/\/maps.googleapis.com\/maps\/api\/staticmap?size=764x400¢er="+lat+","+long+"&zoom=25&markers="+lat+","+long,
"item_url": "http:\/\/maps.apple.com\/maps?q="+lat+","+long+"&z=16"
}
}
}
}
}
}发布于 2017-03-21 18:47:23
德米特里,谢谢你的攻击!FB API略有变化,以下是我在有效负载部分的工作:
payload = dict()
payload['type'] = 'template'
payload['text'] = dict(
template_type="generic",
elements=[
dict(
title='{venue} location',
# subtitle='Test',
image_url="https://maps.googleapis.com/maps/api/staticmap?size=764x400¢er=" + lat + "," + long +
"&zoom=15&markers=" + lat + "," + long,
default_action=dict(
type="web_url",
url="http://maps.apple.com/maps?q=" + venue + "&ll=" + lat + "," + long +
"&z=15"
)
) # buttons=[])
]
)https://stackoverflow.com/questions/38017382
复制相似问题