I am sending message from Facebook whatsapp api to my number for testing. Message is sent from php but not recieved on mobile. Did I must register business on facebook?
{"messaging_product":"whatsapp","contacts":[{"input":"923040165804","wa_id":"923040165804"}],"messages":[{"id":"wamid.HBgMOTIzMDQwMTY1ODA0FQIAERgSOEM3RDJDRDMyMkFENkIzMTgyAA=="}]}
this php code that I am using.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://graph.facebook.com/v13.0/********/messages/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>json_encode(array("to"=> $number, "messaging_product" => 'whatsapp', "recipient_type" => 'individual',"type"=>"text", 'text'=> array('body'=>'hello_wo332233rld','preview_url'=>'false'))),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$chatApiToken,
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
3
Answers
Same issue here. And sending from dev console template, same issue too.
After change the phone number, it has worked. I don’t know if will work at the production environment, but…
Hey I came across the same problem and the solution was to upgrade whatsapp to the latest version on my phone. I added some troubleshooting issues to the Ruby library that could help with similar problems.
Here is a sample code, hope it helps. It works for me
Point to remember
Mentioning a template name is mandatory. The messages are subject to the approved templates
This finally echos the result as
And the message is getting received.
refer the following thread on how to pass a parameter AKA "passing components"
How to send the components in whatsapp cloud api?