Whatsapp API php 代码请求
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27032392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Whatsapp API php code request
提问by Gowri
Following is my code to CodeRequest.
以下是我对 CodeRequest 的代码。
$username = "91xxxxxxxxxx";
$identity = strtolower(urlencode(sha1($username, true)));
$w = new WhatsProt($username, $identity, "test", true);
$r = $w->codeRequest();
print_r($r);
It gives the response as
它给出的响应为
stdClass Object ( [status] => sent [length] => 6 [method] => sms [retry_after] => 1805 )
But I'm not receiving message. Any suggestions please.
但是我没有收到消息。请提出任何建议。
My other questions.
我的其他问题。
- Is there any restriction to request code.(Every time I use new mobile number).?
- For example I request a code for mobile number
xxx
with user agentgalaxys3
shall i request another code with mobile numberyyy
using the same user agent?
- 请求代码有什么限制吗(每次我用新的手机号码)?
- 例如,我
xxx
通过用户代理galaxys3
请求一个手机号码代码,我应该yyy
使用同一个用户代理请求另一个带有手机号码的代码吗?
I'm using WhatsAPI-Official
我正在使用WhatsAPI-Official
采纳答案by Gowri
Finally I received code to mobile.
最后我收到了手机的代码。
$username = "91xxxxxxxxxx";
$identity = "myIdentity";
$w = new WhatsProt($username, $identity, "test", true);
$r = $w->codeRequest('sms',$carrier);
(or)
$r = $w->codeRequest('voice',$carrier); //Voice service is fast compared to sms
$carrier
is getting from networkinfo.csv
file.
$carrier
正在从networkinfo.csv
文件中获取。
carrier is nothing but mobile network operator(Airtel,Idea etc.,) according to your mobile country code(mcc) and mobile network code (mnc).
根据您的移动国家代码 (mcc) 和移动网络代码 (mnc),运营商只不过是移动网络运营商(Airtel、Idea 等)。
You can get the mnc and mcc codes from mobile-network-codes-country-codes
您可以从mobile-network-codes-country-codes获取 mnc 和 mcc代码
Get mcc and mnc codes with your location and operation match them with networkinfo.csv
to get carrier
name.
获取与您的位置和操作匹配的 mcc 和 mnc 代码networkinfo.csv
以获取carrier
名称。
Eg: My number is 919xxxxxx
country - india ( Andhra Pradesh )
operator - Idea
For above link mcc and mnc are for my number is 404 & 7
对于上面的链接 mcc 和 mnc 是我的号码是 404 & 7
Now check those codes in networkinfo.csv
file
现在检查networkinfo.csv
文件中的那些代码
i.e
404,1028,007,7,in,India,91,Idea Cellular Ltd.4
IE
404,1028,007,7,in,India,91,Idea Cellular Ltd.4
Here 404 -> mcc
and 007 -> mnc
这里404 -> mcc
和 007 -> mnc
My carrier name is Idea Cellular Ltd.4
我的运营商名称是 Idea Cellular Ltd.4
If you send correct carrier name you will get sms/call to mobile.
如果您发送正确的运营商名称,您将收到短信/电话。
回答by user1305194
Try this piece of code.
试试这段代码。
$destinationPhone = 'xxxxxxxxxxxx';
$w = new WhatsProt($userPhone, $userIdentity, $userName, $debug);
$w->Connect();
$w->LoginWithPassword($password);
$w->Message($destinationPhone, $argv[1]);
or more info refer this link.. http://blog.philippheckel.com/2013/07/07/send-whatsapp-messages-via-php-script-using-whatsapi/#Send-WhatsApp-messages
或更多信息请参阅此链接.. http://blog.philippheckel.com/2013/07/07/send-whatsapp-messages-via-php-script-using-whatsapi/#Send-WhatsApp-messages