gpt4 book ai didi

facebook-messenger - 如何从 Facebook Messenger 平台发送位置?

转载 作者:行者123 更新时间:2023-12-04 01:30:12 30 4
gpt4 key购买 nike

有一种方法可以将我的位置从移动客户端发送到 facebook-messenger,但是如何从机器人发送一些位置? (信使平台api)

当我尝试从 bot 发送类似的结构时,出现错误:(#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}}
}

最佳答案

德米特里,谢谢你的黑客! 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&center=" + 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=[])
]
)

关于facebook-messenger - 如何从 Facebook Messenger 平台发送位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38017382/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com