繁体   English   中英

WhatsApp 云 Api - Header 和正文模板消息 Php

[英]WhatsApp Cloud Api - Header & Body Template Message Php

我正在尝试使用 Whatsapp Cloud API 发送 WhatsApp 模板消息。

我收到一个错误:

参数“模板”上的意外键“0”。 [类型]

这是我通过 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),
                )
            )
        )
   )

看起来您在components属性中传递了错误的属性数组(包含body类型),

它应该是,

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
                    )
                )
            )
        )
    )
)

我试图输入该代码,但它显示了一个错误。 我们做了一个模板,在header中有一个图像,我们也想放文字,这正是我们需要的,但是在php中,你有例子吗?

您应该创建什么样的模板来使用此代码?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM