Whatsapp API (#132000) 参数数量与预期参数数量不匹配

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

我在 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"
}

}

api message whatsapp payload
5个回答
27
投票

由于关闭模板对象然后打开新的组件对象而导致的问题。 将组件对象放在模板对象中,它将被修复

{
"messaging_product": "whatsapp", 
"to": "918456712349", 
"type": "template", 
"template": { 
    "name": "order_notification",
    "language": { 
        "code": "en_US" 
    }

"components": [
    {
        "type": "body",
        "parameters": [
            {
                "type": "text",
                "text": "135345345"
            }
        ]
    }
]
}
}


1
投票

更改参数类型“header”,此代码为我运行:

 {
    "messaging_product": "whatsapp", 
    "to": "918456712349", 
    "type": "template", 
    "template": { 
        "name": "order_notification",
        "language": { 
            "code": "en_US" 
        },
    "components": [
        {
            "type": "header",
            "parameters": [
                {
                    "type": "text",
                    "text": "xxxxxxx"
                }
            ]
        }
      ]
    }
 }

0
投票

我遇到了同样的问题,我更改了参数结构如下:

            $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],
                            ],
                        ],
                    ],
                ],
            ];

0
投票

{ “messaging_product”:“whatsapp”, “至”:“+919745270094”, “类型”:“模板”, “模板”: { “名称”:“otp_dibiz”, “语言”: { “代码”:“en_US” } }, “成分”: [ { “类型”:“身体”, “参数”: [ { “类型”:“文本”, “文本”:“123456” } ] } ] }


-4
投票

模板似乎需要 1 个参数,但未提供该参数。

您可以在此处查看文档和示例。

它包括一个工作示例。

© www.soinside.com 2019 - 2024. All rights reserved.