简体   繁体   中英

How to receive the media id from the Whatsapp Business Cloud API?

I have deployed my webhook and connected my WABA. Once I send an image to this business account. It did not return the media id from the response. Actually, the JSON returned to me like this:

{
    "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? https://developers.facebook.com/docs/whatsapp/on-premises/reference/media/media-id

You have to chooose the image_id from the request you receive.

like, 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. Then you can download the image from the URL received and uploaded it anywhere you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM