我下载了库https://github.com/mgp25/Chat-API.这个API whatsapp.我做了文档中所写的所有内容(github.com/mgp25/Chat-API/wiki).
首先,我写了以下脚本:
<?php
require_once 'src/Registration.php';
$debug = true;
$username = '123456789'; //my phone number
$w = new Registration($username, $debug);
$w->codeRequest('sms');
?>
Run Code Online (Sandbox Code Playgroud)
然后,在我的手机上收到一条带有注册码的消息.接下来,我编写了以下脚本:
<?php
require_once 'src/Registration.php';
$debug = true;
$username = '123456789';
$w = new Registration($username, $debug);
$w->codeRegister('654321'); //?ode, that I have received
?>
Run Code Online (Sandbox Code Playgroud)
作为回应,我收到:
[status] => ok
[login] => login
[pw] => password
[type] => existing
[expiration] => 1443256747
[kind] => free
[price] => 39.0
[cost] => 0.89
[currency] => ???
[price_expiration] => 1414897682
Run Code Online (Sandbox Code Playgroud)
接下来,我尝试登录:
<?php
set_time_limit(10); …Run Code Online (Sandbox Code Playgroud)