本文整理汇总了PHP中WhatsProt::codeRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::codeRequest方法的具体用法?PHP WhatsProt::codeRequest怎么用?PHP WhatsProt::codeRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::codeRequest方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requestRegister
/** SET CONFIGURATION REQUEST CODE**/
public function requestRegister($codeRegister, $codeRequest = 'sms')
{
$this->managerWhats->codeRequest($codeRequest);
$result = $this->managerWhats->codeRegister($codeRegister);
$result['login'] = "Seu usuário é: " . $result->login;
$result['password'] = "Sua senha é: " . $result->pw;
return $result;
}
示例2: sendCodeRequest
/**
* Send the code for request the WhatsApp password to it own phone
*
* The option for method can be:
* - WhatsAppApi::CODE_REQUEST_TYPE_SMS
* - WhatsAppApi::CODE_REQUEST_TYPE_VOICE
*
* @param string $method The method should be sms or voice
* @return null|WhatsAppResponse
*/
public function sendCodeRequest($method = WhatsAppApi::CODE_REQUEST_TYPE_SMS)
{
try {
$result = $this->wa->codeRequest($method);
return new WhatsAppResponse($result);
} catch (TooRecentException $e) {
return $e->getResponse();
} catch (TooManyGuessesException $e) {
return $e->getResponse();
} catch (ResponseException $e) {
return $e->getResponse();
} catch (\Exception $e) {
return null;
}
}
示例3: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->line('==============================/');
$this->line('Registering WhatsApp');
$this->line('==============================/');
$numbers = Number::where('type', 'like', 'mobile%')->where('features', 'like', '%SMS%')->get(array('number'))->map(function ($number) {
return $number->number;
})->toArray();
if (empty($numbers)) {
return $this->error('No mobile number found.');
}
$number = $this->choice('Choose which number to register.', $numbers);
$numberObj = Number::where('number', $number)->first();
if ($numberObj->voice_callback_type != 'tel') {
$newNumber = $this->ask('Enter your personal mobile number to receive whatsapp verification code.');
$numberObj->voice_callback_type = 'tel';
$numberObj->voice_callback_value = $newNumber;
$isSaved = $numberObj->save();
if (!$isSaved) {
return $this->error('Number is fail to update.');
}
}
// confirm personal number to forward call
$isNumberOkay = $this->confirm('Verification code will be sent to this number, ' . $numberObj->voice_callback_value . '. Proceed?', true);
if (!$isNumberOkay) {
return;
}
// registering
$proceed = $this->confirm('This is very important. You will receive the verification code via phone call, you have to key in the code before the phone call end (around 30 secs) and correct on first try, otherwise you have to wait for 30 mins to 24 hours to get another verification code. Proceed?', true);
$wa = new WhatsProt($number, $number, false);
try {
$waResponse = $wa->codeRequest('voice');
if ($waResponse->status != 'ok') {
$verificationCode = str_replace('-', '', $this->ask('Enter your verification code.'));
$waResponse = $wa->codeRegister($verificationCode);
}
$numberObj->wa_password = $waResponse->pw;
//$numberObj->wa_identity = $waResponse->identity;
$numberObj->wa_expiration = $waResponse->expiration;
$numberObj->save();
$this->line('Done. Run following command in supervisord, php artisan whatsapp:start ' . $number);
} catch (Exception $e) {
$this->error($e->getMessage());
}
}
示例4: trim
<?php
require_once '../src/whatsprot.class.php';
$debug = true;
echo "####################\n";
echo "# #\n";
echo "# WA Register Tool #\n";
echo "# #\n";
echo "####################\n";
echo "\n\nUsername (country code + number without + or 00): ";
$username = trim(fgets(STDIN));
// Create a instance of WhastPort.
$w = new WhatsProt($username, '', $debug);
echo "\n\nType sms or voice: ";
$option = fgets(STDIN);
try {
$w->codeRequest(trim($option));
} catch (Exception $e) {
echo $e->getMessage();
exit(0);
}
echo "\n\nEnter the received code: ";
$code = str_replace("-", "", fgets(STDIN));
try {
$result = $w->codeRegister(trim($code));
echo "\nYour password is: " . $result->pw . "\n";
} catch (Exception $e) {
echo $e->getMessage();
exit(0);
}
示例5:
* @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.
示例6: trim
echo "####################\n";
echo "# #\n";
echo "# WA Register Tool #\n";
echo "# #\n";
echo "####################\n";
echo "\n\nUsername (country code + number without + or 00): ";
$username = trim(fgets(STDIN));
$identity = "identity";
echo "\nNickname: ";
$nickname = trim(fgets(STDIN));
echo "\nCarrier: ";
$carrier = trim(fgets(STDIN));
// Create a instance of WhastPort.
$w = new WhatsProt($username, $identity, $nickname, $debug);
echo "\n\nType sms or voice: ";
$option = fgets(STDIN);
try {
$w->codeRequest(trim($option), $carrier);
} catch (Exception $e) {
echo $e->getMessage();
exit(0);
}
echo "\n\nEnter the received code: ";
$code = fgets(STDIN);
try {
$result = $w->codeRegister(trim($code));
echo "\nYour password is: " . $result->pw . "\n";
} catch (Exception $e) {
echo $e->getMessage();
exit(0);
}
示例7: elseif
$content .= "<form method='post' action='" . elgg_get_site_url() . "enriver/setup/whatsapp/{$segments['2']}/2'>";
$content .= "<br><table><tr><td><label>Mobile Number </label></td><td><input type='text' style='width:400px;'name='mobile'></td></tr>";
$content .= "<tr><td><label>IMEI </label></td><td><input type='text' style='width:400px; name='imei'></td></tr>";
$content .= "<tr><td><label>Nick Name </label></td><td><input type='text' style='width:400px; name='nickname'></td></tr>";
$content .= "<tr><td colspan='2'><input type='submit' class='elgg-button elgg-button-action' name='submit'><td></tr></table></form>";
} elseif ($step == '2') {
$group->whatsapp_mobile = $_POST['mobile'];
$group->whatsapp_imei = $_POST['mobile'];
$group->whatsapp_name = $_POST['mobile'];
$group->save();
require elgg_get_plugins_path() . 'enriver/vendors/whatsapi/whatsprot.class.php';
//echo ."/".."/". ;
$wa = new WhatsProt($_POST['mobile'], $_POST['imei'], $_POST['nickname'], false);
$wa->eventManager()->bind("onCodeRequest", "enriver_onCodeRequest");
$wa->connect();
$wa->codeRequest();
for ($i = 0; $i < 5; $i++) {
$wa->pollMessages();
}
$content = "<h2>You will get 6 digit code on your mobile,Enter the 6 digit code here (without dash)";
$content .= "<form method='post' action='" . elgg_get_site_url() . "enriver/setup/whatsapp/{$segments['2']}/3'>";
$content .= "<input type='text' name='code'>";
$content .= "<input type='submit' name='submit'></form>";
} elseif ($step == '3') {
require elgg_get_plugins_path() . 'enriver/vendors/whatsapi/whatsprot.class.php';
$wa = new WhatsProt($group->whatsapp_mobile, $group->whatsapp_imei, $group->whatsapp_name, false);
$wa->eventManager()->bind("onCodeRegister", "enriver_onCodeRegister");
$wa->connect();
$wa->codeRegister($_POST['code']);
for ($i = 0; $i < 5; $i++) {
$wa->pollMessages();
示例8: strtolower
if (isset($_POST['smscode']) and strlen($_POST['smscode']) == 6) {
$smscode = $_POST['smscode'];
require_once '../lib/user/profile.php';
$identity = strtolower(urlencode(sha1($phone, true)));
$w = new WhatsProt($phone, $identity, $login, false);
try {
$result = $w->codeRegister($smscode);
$password = $result->pw;
$user = new User();
$user->connectDB();
$user->newRealUser($phone, $password, $login);
echo "Success!</br>Your Password is {$password} </br> Запомните или запишите!";
} catch (Exception $e) {
echo $e->getMessage();
}
} else {
$identity = strtolower(urlencode(sha1($phone, true)));
$w = new WhatsProt($phone, $identity, $login, false);
try {
$w->codeRequest();
echo "<label>";
echo '<span class="block input-icon input-icon-right">';
echo '<input type="text" id="code" class="span12" placeholder="enter sms code without lines" />';
echo "<i class=\"icon-lock\"></i>";
echo "</span>";
echo "</label>";
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
示例9: array
if (!file_exists($fileName)) {
$db = new \PDO("sqlite:" . $fileName, null, null, array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$db->exec('CREATE TABLE data (`username` TEXT, `password` TEXT, `nickname` TEXT, `login` TEXT)');
$sql = 'INSERT INTO data (`username`, `password`, `nickname`, `login`) VALUES (:username, :password, :nickname, :login)';
$query = $db->prepare($sql);
$query->execute(array(':username' => $argv[1], ':password' => $argv[2], ':nickname' => $argv[3], ':login' => '1'));
}
}
if (!file_exists($fileName)) {
echo "Welcome to CLI WA Client\n";
echo "========================\n\n\n";
echo "Your number > ";
$number = trim(fgets(STDIN));
$w = new WhatsProt($number, $nickname, $debug);
try {
$result = $w->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 = $w->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 > ";