[英]WhatsApp Cloud Api - Header & Body Template Message Php
I am trying to send a WhatsApp template message using Whatsapp Cloud API.我正在尝试使用 Whatsapp Cloud API 发送 WhatsApp 模板消息。
I am getting an error:我收到一个错误:
Unexpected key "0" on param "template".
参数“模板”上的意外键“0”。 [type]
[类型]
This is the Request that I am sending via Curl Post:这是我通过 Curl 发布的请求:
"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),
)
)
)
)
It looks like you have passed the wrong property array (that contains the body
type) in components
property,看起来您在
components
属性中传递了错误的属性数组(包含body
类型),
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
)
)
)
)
)
)
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?
我们做了一个模板,在header中有一个图像,我们也想放文字,这正是我们需要的,但是在php中,你有例子吗?
What kind of template should you create to work with this code?您应该创建什么样的模板来使用此代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.