You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Messenger API获取用户位置求助:Location Quick Reply在API4.0已废弃

解决Messenger API 4.0+获取用户位置的问题

问题根源

你碰到的报错是因为API 4.0及以上版本已彻底弃用content_type: "location"类型的快速回复,必须使用官方指定的替代方案。

正确请求示例

改用请求用户位置按钮实现位置获取,以下是完整请求JSON:

{
  "recipient": {
    "id": "userid"
  },
  "message": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "button",
        "text": "To assist you better, could you please share your location?",
        "buttons": [
          {
            "type": "request_user_location",
            "title": "Share My Location"
          }
        ]
      }
    }
  }
}

关键说明

  • 按钮必须包含title字段,用于在聊天界面显示按钮文本
  • 用户点击按钮后,会触发系统原生的位置授权弹窗,授权成功后,Messenger会通过webhook将位置数据推送给你的服务
  • 位置数据会包含在message.attachments数组中,具体坐标信息在attachments[0].payload.coordinates字段(包含lat和long)

内容的提问来源于stack exchange,提问作者Achraf Chrouda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 16:18:23