whatsapp api,动态url按钮,参数缺失

问题描述 投票:0回答:1

我尝试使用包含动态 URL 按钮的模板,但我不断收到以下错误:

{"error":{"message":"(#131008) 必需参数为 缺少”,“类型”:“OAuthException”,“代码”:131008,“error_data”:{“messaging_product”:“whatsapp”,“详细信息”:“按钮: Url 类型索引 0 处的按钮需要 参数"},"fbtrace_id":"A5zKyCl8YbQvpCIT7mgmgtC"}}

我错过了什么? 我正在使用 PHP curl 发送消息。 发送不带参数的 hello_world 默认模板效果很好。

这是我使用的查询:

{
"messaging_product": "whatsapp",
"to": "001555444555",
"type": "template",
"template": {
"name": "invitation",
"language": {
"code": "he"
}
},
"components": [
{
"type": "body"
},
{
"type":"button",
"sub_type":"url",
"index":0,
"parameters":[
{
"type":"text",
"text":"1234567"
}
]
}
]
}
php url button dynamic whatsapp
1个回答
0
投票

看来您没有正确阅读文档,我可以看到您没有准备正确的请求对象,

https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#template-object

我不知道您的模板部分,但这只是根据您的请求预测的请求,

  • components
    属性应该位于模板属性内部
  • 如果正文中没有任何参数,则无需在请求中传递正文
{
  "messaging_product": "whatsapp",
  "to": "001555444555",
  "type": "template",
  "template": {
    "name": "invitation",
    "language": {
      "code": "he"
    },
    "components": [
      {
        "type": "button",
        "sub_type": "url",
        "index": 0,
        "parameters": [
          {
            "type": "text",
            "text": "1234567"
          }
        ]
      }
    ]
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.