如何将图像添加到WhatsApp API中的变量中?

发布于 2025-02-11 05:39:48 字数 69 浏览 1 评论 0原文

嗨,我正在尝试使用WhatsApp API发送图像,我像这样做了我的模板:

Hola *{{1}}* 
              

Hi I am trying to send an image with Whatsapp api, I did my template like this one:

Hola *{{1}}* ????‍♀️????‍♂️

Hemos cargado una nueva noticia en la intranet, si quieres visualizar la misma haz click en el 
siguiente enlace: {{2}}

???? *Jis Parking*

and my code is this one:

{
"to": "xxxxx",
"recipient_type": "individual",
"type": "template",
"template": {
    "namespace": "88b39973_f0d5_54e1_29cf_e80f1e3da4f2",
    "name": "noticia",
    "language": {
        "code": "es"
    },
    "components": [
        {
            "type": "body",
            "parameters": [
                {
                    "type": "text",
                    "text": "Richard"
                },
                {
                    "type": "image",
                    "image": {
                        "link": "image_url"
                    }
                }
            ] 
        }
    ]
   }
 }

I added the image_url and it's weird because I see all good and the api displays this error:

{
  "error": {
    "message": "(#100) The parameter messaging_product is required.",
    "type": "OAuthException",
    "code": 100,
    "fbtrace_id": "AxtiGLSBvAZltlMkJAw-GIk"
  }
}

I wonder what am I doing wrong? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溇涏 2025-02-18 05:39:48

嘿,您是否首先上传了图像?

要获取ID链接首先,您需要使用API​​上传媒体,该API将返回媒体对象,并使用ID 和<代码>链接。

我使用 whatsapp ruby​​ sdk 与API连接,看起来像这样:

uploaded_media = medias_api.upload(sender_id: SENDER_ID, file_path: "tmp/whatsapp.png", type: "image/png")
media = medias_api.media(media_id: uploaded_media.data&.id).data

Hey did you upload the image first?

To get an id or a link first you need to upload the media using the API which would return a media object with ID and a link.

I use the Whatsapp Ruby SDK for connecting with the API which looks like this:

uploaded_media = medias_api.upload(sender_id: SENDER_ID, file_path: "tmp/whatsapp.png", type: "image/png")
media = medias_api.media(media_id: uploaded_media.data&.id).data
寒尘 2025-02-18 05:39:48

首先,当前错误说您需要在请求中添加以下参数,

"messaging_product" : "whatsapp"

其次,我在您的请求中注意到,image类型不支持body键入组件。 ,身体类型支持这三种类型的值文本货币date_time,有关更多详细信息,请查看 documentation

如果您想在消息中添加图像,您必须使用header键入image,对于Ex:

“在此处inter

之后,您可以将图像添加到标题组件,有关更多详细信息,请查看文档

First, the current error says you need to add the below parameter in your request,

"messaging_product" : "whatsapp"

Second, I notice in your request, that the image type is not supported in body type component, the body type supports these 3 types of values text, currency, date_time, for more details review the documentation,

If you want to add an image to your message, you have to create a new template with a header type as image, for ex:

enter image description here

After that, you can add an image to the header component, for more details review the documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文