protected function waitForLogin()
    {
        $retryTime = 10;
        $tip = 1;

        $this->vbot->console->log('please scan the qrCode with wechat.');
        while ($retryTime > 0) {
            $url = sprintf('https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s', $tip, $this->vbot->config['server.uuid'], time());

            $content = $this->vbot->http->get($url, ['timeout' => 35]);

            preg_match('/window.code=(\d+);/', $content, $matches);

            $code = $matches[1];
            switch ($code) {
                case '201':
                    $this->vbot->console->log('please confirm login in wechat.');
                    $tip = 0;
                    break;
                case '200':
                    preg_match('/window.redirect_uri="(https:\/\/(\S+?)\/\S+?)";/', $content, $matches);

                    $this->vbot->config['server.uri.redirect'] = $matches[1].'&fun=new';
                    $url = 'https://%s/cgi-bin/mmwebwx-bin';
                    $this->vbot->config['server.uri.file'] = sprintf($url, 'file.'.$matches[2]);
                    $this->vbot->config['server.uri.push'] = sprintf($url, 'webpush.'.$matches[2]);
                    $this->vbot->config['server.uri.base'] = sprintf($url, $matches[2]);

                    return;
                case '408':
                    $tip = 1;
                    $retryTime -= 1;
                    sleep(1);
                    break;
                default:
                    $tip = 1;
                    $retryTime -= 1;
                    sleep(1);
                    break;
            }
        }

        $this->vbot->console->log('login time out!', Console::ERROR);

        throw new LoginTimeoutException('Login time out.');
    }
protected function waitForLogin()
    {
        $retryTime = 10;
        $tip = 1;

        $this->vbot->console->log('please scan the qrCode with wechat.');
        while ($retryTime > 0) {
            $url = sprintf('https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s', $tip, $this->vbot->config['server.uuid'], time());

            $content = $this->vbot->http->get($url, ['timeout' => 35]);

            preg_match('/window.code=(\d+);/', $content, $matches);

            $code = $matches[1];
            switch ($code) {
                case '201':
                    $this->vbot->console->log('please confirm login in wechat.');
                    $tip = 0;
                    break;
                case '200':
                    preg_match('/window.redirect_uri="(https:\/\/(\S+?)\/\S+?)";/', $content, $matches);

                    $this->vbot->config['server.uri.redirect'] = $matches[1].'&fun=new';
                    $url = 'https://%s/cgi-bin/mmwebwx-bin';
                    $this->vbot->config['server.uri.file'] = sprintf($url, 'file.'.$matches[2]);
                    $this->vbot->config['server.uri.push'] = sprintf($url, 'webpush.'.$matches[2]);
                    $this->vbot->config['server.uri.base'] = sprintf($url, $matches[2]);

                    return;
                case '408':
                    $tip = 1;
                    $retryTime -= 1;
                    sleep(1);
                    break;
                default:
                    $tip = 1;
                    $retryTime -= 1;
                    sleep(1);
                    break;
            }
        }

        $this->vbot->console->log('login time out!', Console::ERROR);

        throw new LoginTimeoutException('Login time out.');
    }
protected function waitForLogin ( ) { $ retryTime = 10 ; $ tip = 1 ; $ this -> vbot -> console -> log ( 'please scan the qrCode with wechat.' ) ; while ( $ retryTime > 0 ) { $ url = sprintf ( 'https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s' , $ tip , $ this -> vbot -> config [ 'server.uuid' ] , time ( ) ) ; $ content = $ this -> vbot -> http -> get ( $ url , [ 'timeout' => 35 ] ) ; preg_match ( '/window.code=(\d+);/' , $ content , $ matches ) ; $ code = $ matches [ 1 ] ; switch ( $ code ) { case '201' : $ this -> vbot -> console -> log ( 'please confirm login in wechat.' ) ; $ tip = 0 ; break ; case '200' : preg_match ( '/window.redirect_uri="(https:\/\/(\S+?)\/\S+?)";/' , $ content , $ matches ) ; $ this -> vbot -> config [ 'server.uri.redirect' ] = $ matches [ 1 ] . '&fun=new' ; $ url = 'https://%s/cgi-bin/mmwebwx-bin' ; $ this -> vbot -> config [ 'server.uri.file' ] = sprintf ( $ url , 'file.' . $ matches [ 2 ] ) ; $ this -> vbot -> config [ 'server.uri.push' ] = sprintf ( $ url , 'webpush.' . $ matches [ 2 ] ) ; $ this -> vbot -> config [ 'server.uri.base' ] = sprintf ( $ url , $ matches [ 2 ] ) ; return ; case '408' : $ tip = 1 ; $ retryTime -= 1 ; sleep ( 1 ) ; break ; default : $ tip = 1 ; $ retryTime -= 1 ; sleep ( 1 ) ; break ; } } $ this -> vbot -> console -> log ( 'login time out!' , Console :: ERROR ) ; throw new LoginTimeoutException ( 'Login time out.' ) ; }
waiting user to login.

@throws \Exception
waiting user to login .