本文整理汇总了PHP中Registration::codeRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Registration::codeRequest方法的具体用法?PHP Registration::codeRequest怎么用?PHP Registration::codeRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registration
的用法示例。
在下文中一共展示了Registration::codeRequest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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: ' . $response->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: registerNumberAction
/** 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:
* @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: register
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: copy
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: trim
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 = "' . $username . '"' . ";\n");
fwrite($fp, '$nickname = "' . $nome . '"' . ";\n");
fclose($fp);
}
echo "OK";
} catch (Exception $e) {
// echo $e->getMessage();
exit(0);
}
}
exit;