这是我从 WhatsApp API 发送个人或自定义消息的代码
====================================
$token='654464645321813vbnj3hj5g3jg1j5g3j131j3ghj1';
$telefono = '44596565965';
$url = 'https://graph.facebook.com/v16.0/109571185362363/messages';
$mensaje=''
.'{'
.'"messaging_product": "whatsapp",'
.'"recipient-type": "individual",'
.'"to": "'.$telefono.'",'
.'"type":"text",'
.'"text": '
.'{'
.'"preview_url": "false",'
.'"body": ""hello que tal world"'
.'}'
.'}';
$header = array("Authorization: Bearer " . $token, "Content-Type: application/json",);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POSTFIELDS, $mensaje);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = json_decode(curl_exec($curl), true);
print_r($response);
$status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
?>
==================================
问题不是什么都不发送,代码不显示错误但不发送消息,如果使用模板是的,但这样就不行了
结果是这样的:
Array ( [messaging_product] => whatsapp [contacts] => Array ( [0] => Array ( [input] => 44596565965[wa_id] => 44596565965 ) ) [messages] => Array ( [0] => Array ( [id] => wamid.HBgLMzQ2MzI4Njc4NTgVAgARGBI1MUNBQUVGOTM3NkE1MjZFREIA ) ) )
我尽一切努力在官方 API 中寻找解决方案,但一无所获。