我正在尝试将音频发送到whatsapp API,在代码和返回下方,它返回成功,但音频未到达手机上
发送媒体
curl --request POST \
--url https://graph.facebook.com/v17.0/xxxxxxxxxx/media \
--header 'Authorization: Bearer EAAD....' \
--header 'Content-Type: multipart/form-data' \
--form file=@/Users/2_1687628467.mp3 \
--form type=audio/mp3 \
--form messaging_product=whatsapp
返回
{
"id": "969850597766683"
}
发送消息
curl --request POST \
--url https://graph.facebook.com/v17.0/xxxxxxxxxx/messages \
--header 'Authorization: Bearer EAAD...' \
--header 'Content-Type: application/json' \
--data '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "MY_PHONE_NUMBER",
"type": "audio",
"audio": {
"id": "969850597766683"
}
}'
返回发送消息
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "MY_PHONE_NUMBER",
"wa_id": "MY_PHONE_NUMBER"
}
],
"messages": [
{
"id": "wamid.HBgMNTU2NTkyNjY1MDYwFQI=="
}
]
}
检查您创建音频所用的 mime 类型,它应该是audio/mpeg