Пример #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $number = $input->getOption('number');
     $debug = true;
     try {
         // Create a instance of Registration class.
         $r = new \Registration($number, $debug);
         $r->codeRequest('sms');
         // could be 'voice' too
     } catch (\Exception $e) {
         $output->writeln('<error>the number is invalid ' . $number . '</error>');
         return false;
     }
     $helper = $this->getHelper('question');
     $question = new Question('Digite seu código de confirmação recebido por SMS (sem hífen "-"): ', false);
     $question->setValidator(function ($value) use($output, $r) {
         try {
             $response = $r->codeRegister($value);
             $output->writeln('<fg=green>Your password is: ' . $response->pw . ' and your login: '******'</>');
         } catch (\Exception $e) {
             $output->writeln("<error>Código inválido, tente novamente mais tarde!</error>");
             return false;
         }
         return true;
     });
     $codigo = $helper->ask($input, $output, $question);
     $output->writeln('<fg=green>Your number is ' . $number . ' and your code: ' . $codigo . '</>');
 }
Пример #2
0
 /** REGISTER NUMBER ***/
 public function registerNumberAction()
 {
     $request = $this->getRequest();
     $debug = true;
     $result = false;
     $username = null;
     $nickname = null;
     if ($request->isPost()) {
         $data = $request->getPost();
         $username = $data['number'];
         // Telephone number including the country code without '+' or '00'.
         $nickname = $data['nickname'];
         $register = new \Registration($username, $debug);
         $result = $register->codeRequest('sms');
     }
     return new ViewModel(array('result' => $result, 'username' => $username, 'nickname' => $nickname));
 }
Пример #3
0
 * @param $method
 *   Accepts only 'sms' or 'voice' as a value.
 * @param $countryCody
 *   ISO Country Code, 2 Digit.
 * @param $langCode
 *   ISO 639-1 Language Code: two-letter codes.
 *
 * @return object
 *   An object with server response.
 *   - status: Status of the request (sent/fail).
 *   - reason: Reason of the status (e.g. too_recent/missing_param/bad_param).
 *   - length: Registration code length.
 *   - method: Used method.
 *   - retry_after: Waiting time before requesting a new code.
 */
$w->codeRequest('sms');
// You must wait until you receive a code from WhatsApp, either to your phone via sms
// or phonecall depending on what you selected above.
// The function below will only work once you know your code!
/*
 * Second register account on WhatsApp using the provided code with $w->codeRequest();.
 *
 * @param integer $code
 *   Numeric code value provided on codeRequest().
 *
 * @return object
 *   An object with server response.
 *   - status: Account status.
 *   - login: Phone number with country code.
 *   - pw: Account password.
 *   - type: Type of account.
Пример #4
0
 public function register($code = '', $method = 'sms')
 {
     require_once $this->phpbb_root_path . 'ext/tas2580/mobilenotifier/vendor/Chat-API/Registration.' . $this->php_ext;
     $r = new \Registration($this->config['whatsapp_sender'], $this->debug);
     if (empty($code)) {
         try {
             $response = $r->codeRequest($method);
         } catch (\Exception $e) {
             trigger_error($e->getMessage(), E_USER_WARNING);
         }
     } else {
         try {
             $response = $r->codeRegister($code);
         } catch (\Exception $e) {
             trigger_error($e->getMessage(), E_USER_WARNING);
         }
         $response = (array) $response;
         return isset($response['pw']) ? $response['pw'] : '';
     }
 }
Пример #5
0
    if (!file_exists($fileName)) {
        copy($fileName, $dbFolder . 'data.backup.csv');
    }
    $fp = fopen($fileName, 'c');
    $data = array($argv[1], $argv[2], $argv[3], '1');
    fputcsv($fp, $data);
    fclose($fp);
}
if (!file_exists($fileName)) {
    echo "Welcome to CLI WA Client\n";
    echo "========================\n\n\n";
    echo 'Your number > ';
    $number = trim(fgets(STDIN));
    $r = new Registration($number, $debug);
    try {
        $result = $r->codeRequest('sms');
    } catch (Exception $e) {
        echo 'there is an error' . $e;
    }
    echo "\nEnter sms code you have received > ";
    $code = trim(str_replace('-', '', fgets(STDIN)));
    try {
        $result = $r->codeRegister($code);
    } catch (Exception $e) {
        echo 'there is an error';
    }
    echo "\nYour nickname > ";
    $nickname = trim(fgets(STDIN));
    do {
        echo "Is '{$nickname}' right?\n";
        echo 'yes/no > ';
Пример #6
0
        exit;
    }
    exit;
} else {
    $_SESSION['celular'] = $_GET['celular'];
    //header("Content-type: text/html; charset=utf-8");
    $debug = true;
    //echo "\n\nUsername (country code + number without + or 00): ";
    $username = trim("55" . $_GET['celular']);
    $nome = trim($_GET['nome']);
    $fCode = $_GET['celular'] . ".dat";
    $w = new Registration($username, $debug);
    //		$w = new WhatsProt($username, '', $debug);
    $option = "sms";
    // $w->checkCredentials();
    try {
        $w->codeRequest(trim($option));
        $fp = @fopen("user_config.php", "w");
        if ($fp) {
            fwrite($fp, '<?php' . "\n");
            fwrite($fp, '$username = "******"' . ";\n");
            fwrite($fp, '$nickname = "' . $nome . '"' . ";\n");
            fclose($fp);
        }
        echo "OK";
    } catch (Exception $e) {
        // echo $e->getMessage();
        exit(0);
    }
}
exit;