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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:09:09  来源:igfitidea点击:

Whatsapp API php code request

phpwhatsapp

提问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.

我的其他问题。

  1. Is there any restriction to request code.(Every time I use new mobile number).?
  2. For example I request a code for mobile number xxxwith user agent galaxys3shall i request another code with mobile number yyyusing the same user agent?
  1. 请求代码有什么限制吗(每次我用新的手机号码)?
  2. 例如,我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

$carrieris getting from networkinfo.csvfile.

$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.csvto get carriername.

获取与您的位置和操作匹配的 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.csvfile

现在检查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 -> mccand 007 -> mnc

这里404 -> mcc007 -> 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