WhatsApp / WhatsApp-Business-API-Setup-Scripts

The scripts related to setting up WhatsApp business API
MIT License
404 stars 425 forks source link

How to get the URL of an image in WhatsApp Business Cloud API, while we send an image through WhatsApp #73

Closed MohammedHafiz closed 1 year ago

MohammedHafiz commented 2 years ago

While working on WhatsApp Business Cloud API, I have to send an Image through WhatsApp. When I send that image I am getting a response as a sha256 base64 string and an imageId. I want to retrieve back that image using these credentials. I'm getting a url when I make a get request with that image id. That URL is actually broken/invalid and I'm not getting the image back.

Response of the request is given below :

"messages": [ { "from": "918**6", "id": "wamid.HBgMOT*****EA", "timestamp": "1655978686", "type": "image", "image": { "mime_type": "image/jpeg", "sha256": "ian**jM4k=", "id": "4**7" } } ]

facebook-github-bot commented 2 years ago

Hi MohammedHafiz (https://github.com/MohammedHafiz),

Thank you for your comment. This GitHub repo is not actively monitored. If you need help, please check previously asked questions in the WA Business API Developer Community, or raise a Direct support ticket. Meanwhile, we are happy to continue with less time-sensitive discussions in GitHub.

Thanks for your understanding!

mengyiyuan commented 1 year ago

Hi,

When you first uploaded the media, you should get a media ID back. With that media ID, you can retrieve the media URL with this endpoint: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#retrieve-media-url.

With the url, you need to use a GET request with your access token to download the media: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#download-media.

Hope this helps!