WhatsApp API模板消息带有视频无法发送。

huangapple go评论191阅读模式
英文:

WhatsApp API template message with video not sending

问题

我正在尝试使用WhatsApp API发送包含视频的模板消息。当我发送不包含媒体内容的模板消息时,它们可以成功送达。然而,当我在模板中包含视频时,消息无法发送,并没有出现任何错误消息。

这是我使用的代码:

{
    "messaging_product": "whatsapp",
    "to": "01123456789",
    "type": "template",
    "template": {
        "namespace": "your-trainer",
        "name": "my_template_name",
        "language": {
            "code": "DE",
            "policy": "deterministic"
        },
        "components": [
            {
                "type": "header",
                "parameters": [
                    {
                        "type": "video",
                        "video": {
                            "link": "https://scontent.whatsapp.net/v/t61....."
                        }
                    }
                ]
            },
            {
                "type": "body",
                "parameters": [
                    {
                        "type": "text",
                        "text": "Some custom text for variable"
                    }
                ]
            }
        ]
    }
}

这是我的模板:

"data": [
    {
        "name": "my_template_name",
        "components": [
            {
                "type": "HEADER",
                "format": "VIDEO",
                "example": {
                    "header_handle": [
                        "https://scontent.whatsapp.net/v/t61..."
                    ]
                }
            },
            {
                "type": "BODY",
                "text": "Hallo {{1}}\n\"",
                "example": {
                    "body_text": [
                        [
                            "stackoverflow"
                        ]
                    ]
                }
            },
            {
                "type": "FOOTER",
                "text": "Some Footer-Text"
            },
            {
                "type": "BUTTONS",
                "buttons": [
                    {
                        "type": "QUICK_REPLY",
                        "text": "Promotions stoppen"
                    }
                ]
            }
        ],
        "language": "de",
        "status": "APPROVED",
        "category": "MARKETING",
        "id": "myid"
    }
]

这是响应:

{
    "messaging_product": "whatsapp",
    "contacts": [
        {
            "input": "1234567899",
            "wa_id": "1234567899"
        }
    ],
    "messages": [
        {
            "id": "wamid.HBgLNDE3OTQ2NDg4NjYVAgARGDFSDFSDFSDF"
        }
    ]
}

我是否做错了什么?

英文:

I am trying to send a WhatsApp message using the WhatsApp API with a template that includes a video. When I send templates without media content, they are successfully delivered. However, when I include a video in the template, the message is not sent without any error message.

Here is the code I'm using:

{
"messaging_product": "whatsapp",
"to": "01123456789",
"type": "template",
"template": {
    "namespace": "your-trainer",
    "name": "my_template_name",
    "language": {
        "code": "DE",
        "policy": "deterministic"
    },
    "components": [
        {
            "type": "header",
            "parameters": [
                {
                    "type": "video",
                    "video": {
                        "link": "https://scontent.whatsapp.net/v/t61....."
                    }
                }
            ]
        },
        {
            "type": "body",
            "parameters": [
                {
                    "type": "text",
                    "text": "Some custom text for variable"
                }
            ]
        }
    ]
}}

Here is my template:

    "data": [
    {
        "name": "my_template_name",
        "components": [
            {
                "type": "HEADER",
                "format": "VIDEO",
                "example": {
                    "header_handle": [
                        "https://scontent.whatsapp.net/v/t61..."
                    ]
                }
            },
            {
                "type": "BODY",
                "text": "Hallo {{1}}\n\",
                "example": {
                    "body_text": [
                        [
                            "stackoverflow"
                        ]
                    ]
                }
            },
            {
                "type": "FOOTER",
                "text": "Some Footer-Text"
            },
            {
                "type": "BUTTONS",
                "buttons": [
                    {
                        "type": "QUICK_REPLY",
                        "text": "Promotions stoppen"
                    }
                ]
            }
        ],
        "language": "de",
        "status": "APPROVED",
        "category": "MARKETING",
        "id": "myid"
    }

Here is the response

{
"messaging_product": "whatsapp",
"contacts": [
    {
        "input": "1234567899",
        "wa_id": "1234567899"
    }
],
"messages": [
    {
        "id": "wamid.HBgLNDE3OTQ2NDg4NjYVAgARGDFSDFSDFSDF"
    }
]}

Is there something I'm doing wrong?

答案1

得分: 1

解决方案是通过上传API上传视频,然后使用视频ID。

参见:
https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media

英文:

The solution is to upload a video via Upload API and then use the videoId.

See:
https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media

huangapple
  • 本文由 发表于 2023年6月16日 04:38:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76485365.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定