将消息从Facebook WhatsApp API发送到我的电话号码
我将来自Facebook WhatsApp API的消息发送到我的电话号码进行测试。消息是从PHP发送的,但未在移动设备上收到。我必须在Facebook上注册业务吗?
{"messaging_product":"whatsapp","contacts":[{"input":"923040165804","wa_id":"923040165804"}],"messages":[{"id":"wamid.HBgMOTIzMDQwMTY1ODA0FQIAERgSOEM3RDJDRDMyMkFENkIzMTgyAA==" }]}
我正在使用的此PHP代码。
$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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
同样的问题。并从Dev Console模板发送,也是同一问题。
更改电话号码后,它起作用了。我不知道是否会在生产环境中工作,但是...
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...
嘿,我遇到了同样的问题,解决方案是将WhatsApp升级到手机上的最新版本。我添加了一些故障排除问题 可能会帮助遇到类似问题的Ruby库。
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.
这是示例代码,希望它有帮助。它对我有用
要记住
提及模板名称是强制性的。消息受批准的模板的约束,
这最终与结果相呼应,
并收到消息。
请参阅有关如何传递参数aka的以下线程,也就是“传递组件”
如何在WhatsApp Cloud API中发送组件?
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?