为什么Chat-Api中存在无限循环?

时间:2016-09-23 07:16:49

标签: php api web whatsapp

我下载了库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');
?>

然后,在我的手机上收到一条带有注册码的消息。 接下来,我编写了以下脚本:

<?php
    require_once 'src/Registration.php';

    $debug = true;
    $username = '123456789';

    $w = new Registration($username, $debug);

    $w->codeRegister('654321'); //сode, that I have received
?>

作为回应,我收到了:

  [status] => ok
  [login] => login
  [pw] => password
  [type] => existing
  [expiration] => 1443256747
  [kind] => free
  [price] => 39.0
  [cost] => 0.89
  [currency] => руб
  [price_expiration] => 1414897682

接下来,我尝试登录:

<?php
    set_time_limit(10);
    require_once 'src/whatsprot.class.php';
    require_once 'src/events/MyEvents.php';

    date_default_timezone_set('Europe/Moscow');

    $username = '123456789';                 
    $password = 'password';
    $nickname = 'nickname';                    
    $debug    = true;

    $w = new WhatsProt($username, $nickname, $debug);
    $w->connect();
    $w->loginWithPassword($password);

这里,脚本进入无限循环。 函数loginWithPassword()位于文件whatsprot.class.php中:

    github.com/mgp25/Chat-API/blob/master/src/whatsprot.class.php

在第277行。在第287行调用函数doLogin()。这个函数在Login.php文件中:

    github.com/mgp25/Chat-API/blob/master/src/Login.php

第24行。第49行是无限循环。 这里描述了同样的问题https://github.com/mgp25/Chat-API/issues/2140

1 个答案:

答案 0 :(得分:2)

不幸的是,我认为whatsapp不再支持这个api