我想在whatsapp cloud api中發送引數。我怎樣才能做到這一點。
$messageData = array(
'messaging_product' => "whatsapp",
'to' => "123456789",
'type' => "template",
'template' => array("name"=> "hello_world",'language'=>array("code"=>"en_Us")),
);
我想要這樣
{
type: 'template',
messaging_product: 'whatsapp',
to: e.recipient_number,
template: {
name: WHATSAPP_TEMPLATE_NAME,
language: { code: LANGUAGE_CODE },
components: [
{
type: 'body',
parameters: [
{ type: 'text', text: e.customer_name },
{ type: 'text', text: e.item_name },
{ type: 'text', text: e.delivery_date },
],
},
],
},
}
我得到的錯誤
{"error":{"message":"(#132000) 引數數量與預期的引數數量不匹配","type":"OAuthException","code":132000,"error_data":{"messaging_product" :"whatsapp","details":"body: localizable_params (0) 的數量與預期的引數數量 (3) 不匹配"},"error_subcode":2494073,"fbtrace_id":"Abab9mTp_dJ9Ryd4ytHPl7Y"}}
uj5u.com熱心網友回復:
首先,hello_world模板是一個預定義的模板,由 Whatsapp 業務 API 團隊創建。如果您需要發送引數,您必須創建一個模板,其主體中包含變數,例如
網址 - {{1}}
然后像這樣傳遞引數,
var data = JSON.stringify({
"messaging_product": "whatsapp",
"to": number,
"type": "template",
"template": {
"name": "template_name",
"language": {
"code": "language_code"
},
"components": [
{
"type": "body",
"parameters": [{
"type": "text",
"text":"https://www.whatsapp.com"
}]
}],
}});
您的輸出訊息將是 URL - https://www.whatsapp.com
uj5u.com熱心網友回復:
$messageData = array(
'messaging_product' => "whatsapp",
'to' => 123456789,
'type' => "template",
'template' => array("name"=> "random name",'language'=>array("code"=>"en_Us"),'components'=>
array(array(
"type" => "body",
"parameters" => array(array("type"=> "text","text"=> google.com),array("type"=> "text","text"=> $shopName),array("type"=> "text","text"=> 123456789)))))
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/489590.html
