I am trying to send a WhatsApp template message using Whatsapp Cloud API.
I am getting an error:
Unexpected key "0" on param "template". [type]
This is the Request that I am sending via Curl Post:
"messaging_product"=> "whatsapp",
"recipient_type" => "individual",
"to" => "$to_number",
"type" => "template",
'template' => array("name"=> "templateName",'language'=>array("code"=>"en"),
'components'=>
array(
array(
"type" => "header",
"parameters" => array(
array(
"type" => "image",
"image" => array(
"link" => $imageLink
)
)
)
)
),
array(
array(
"type" => "body",
"parameters" => array(
array("type"=> "text","text"=> $Productid),
)
)
)
)
CodePudding user response:
It looks like you have passed the wrong property array (that contains the body
type) in components
property,
It should be,
array(
'messaging_product' => "whatsapp",
'recipient_type' => "individual",
'to' => "$to_number",
'type' => "template",
'template' => array(
'name' => "templateName",
'language' => array(
'code' => "en"
),
'components' => array(
array(
'type' => "header",
'parameters' => array(
array(
'type' => "image",
'image' => array(
'link' => $imageLink
)
)
)
),
array(
'type' => "body",
'parameters' => array(
array(
'type' => "text",
'text' => $Productid
)
)
)
)
)
)
CodePudding user response:
I tried to enter that code and it shows me an error. We made a template, with an image in the header, and we also want to put text, and it's exactly what we need, but in php, do you have an example?