我在 Whatsapp API 中创建了以下模板。我想在API调用中设置参数值。正确的有效负载是多少?我一直在关注元文档并尝试,但每次都会出错。请帮忙。
模板:
您订购的#{{1}}已成功收到。
我使用了这个有效负载:
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
}
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "135345345"
}
]
}
]
}
但是我仍然收到此错误
{
"error": {
"message": "(#132000) Number of parameters does not match the expected number of params",
"type": "OAuthException",
"code": 132000,
"error_data": {
"messaging_product": "whatsapp",
"details": "body: number of localizable_params (0) does not match the expected number of params (1)"
},
"error_subcode": 2494002,
"fbtrace_id": "AzPa-uWXctIcdNVu0Lf3Fic"
}
}
由于关闭模板对象然后打开新的组件对象而导致的问题。 将组件对象放在模板对象中,它将被修复
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
}
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "135345345"
}
]
}
]
}
}
更改参数类型“header”,此代码为我运行:
{
"messaging_product": "whatsapp",
"to": "918456712349",
"type": "template",
"template": {
"name": "order_notification",
"language": {
"code": "en_US"
},
"components": [
{
"type": "header",
"parameters": [
{
"type": "text",
"text": "xxxxxxx"
}
]
}
]
}
}
我遇到了同样的问题,我更改了参数结构如下:
$parameters = [
"messaging_product" => "whatsapp",
"recipient_type" => "individual",
"to" => $phone,
"type" => "template",
"template" => [
"name" => "otp_code",
"language" => ["code" => "en"],
"components" => [
[
"type" => "body",
"parameters" => [
["type" => "text", "text" => $message],
],
],
],
],
];
{ “messaging_product”:“whatsapp”, “至”:“+919745270094”, “类型”:“模板”, “模板”: { “名称”:“otp_dibiz”, “语言”: { “代码”:“en_US” } }, “成分”: [ { “类型”:“身体”, “参数”: [ { “类型”:“文本”, “文本”:“123456” } ] } ] }