如何将图像添加到WhatsApp API中的变量中?
嗨,我正在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嘿,您是否首先上传了图像?
要获取
ID
或链接
首先,您需要使用API上传媒体,该API将返回媒体对象,并使用ID
和<代码>链接。我使用 whatsapp ruby sdk 与API连接,看起来像这样:
Hey did you upload the image first?
To get an
id
or alink
first you need to upload the media using the API which would return a media object withID
and alink
.I use the Whatsapp Ruby SDK for connecting with the API which looks like this:
首先,当前错误说您需要在请求中添加以下参数,
其次,我在您的请求中注意到,
image
类型不支持body
键入组件。 ,身体类型支持这三种类型的值文本
,货币
,date_time
,有关更多详细信息,请查看 documentation ,如果您想在消息中添加图像,您必须使用
header
键入image
,对于Ex:之后,您可以将图像添加到
标题
组件,有关更多详细信息,请查看文档。First, the current error says you need to add the below parameter in your request,
Second, I notice in your request, that the
image
type is not supported inbody
type component, the body type supports these 3 types of valuestext
,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 asimage
, for ex:After that, you can add an image to the
header
component, for more details review the documentation.