[英]How to receive the media id from the Whatsapp Business Cloud API?
I have deployed my webhook and connected my WABA.我已经部署了我的 webhook 并连接了我的 WABA。 Once I send an image to this business account.一旦我将图像发送到该企业帐户。 It did not return the media id from the response.它没有从响应中返回媒体 ID。 Actually, the JSON returned to me like this:实际上,JSON 是这样返回给我的:
{
"entry": [
{
"changes": [
{
"field": "messages",
"value": {
"contacts": [
{
"profile": {
"name": "XXXXXXX"
}
}
],
"messages": [
{
"from": "XXXXXXXXXX",
"id": "wamid.aisjdoiajsodiajsodasd\u003d",
"timestamp": "1657527108",
"type": "image"
}
],
"metadata": {}
}
}
],
"id": "124071984791824"
}
],
"object": "whatsapp_business_account"
}
Or should I try the Whatsapp On-premises API?或者我应该尝试 Whatsapp On-premises API? https://developers.facebook.com/docs/whatsapp/on-premises/reference/media/media-id https://developers.facebook.com/docs/whatsapp/on-premises/reference/media/media-id
You have to chooose the image_id from the request you receive.您必须从收到的请求中选择 image_id。
like, let media_id=req.body.entry[0].changes[0].value.messages[0].image.id;
比如, let media_id=req.body.entry[0].changes[0].value.messages[0].image.id;
you can store this id in DB and use the endpioint where you can get the url for media_id.您可以将此 ID 存储在数据库中并使用 endpioint,您可以在其中获取 media_id 的 url。 Then you can download the image from the URL received and uploaded it anywhere you want.然后,您可以从收到的 URL 下载图像并将其上传到您想要的任何位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.