本文整理汇总了PHP中WhatsProt::codeRegister方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::codeRegister方法的具体用法?PHP WhatsProt::codeRegister怎么用?PHP WhatsProt::codeRegister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsProt
的用法示例。
在下文中一共展示了WhatsProt::codeRegister方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: sendCodeRegister
/**
* Get the WhatsApp password
*
* @param $code
* @return null|WhatsAppResponse
*/
public function sendCodeRegister($code)
{
try {
$result = $this->wa->codeRegister($code);
$response = new WhatsAppResponse($result);
return $response;
} catch (CodeRegisterFailedException $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:
* - 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.
* - expiration: Expiration date in UNIX Timestamp.
* - kind: Kind of account.
* - price: Formatted price of account.
* - cost: Decimal amount of account.
* - currency: Currency price of account.
* - price_expiration: Price expiration in UNIX Timestamp.
*/
$w->codeRegister('123456');
// IT IS VERY IMPORTANT THAT YOU NOTE AND KEEP YOUR DETAILS.
// YOU WILL NEED TO UPDATE THE SCRIPT WITH THE PASSWORD ETC.
//Use exampleFunctional.php to continue with the examples.
示例6: here
$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();
}
$content = "<h2>Send Test message to other phone number,(make sure other phone has " . $group->whatsapp_mobile . " in contact. ";
$content .= "<form method='post' action='" . elgg_get_site_url() . "enriver/setup/whatsapp/{$segments['2']}/4'>";
$content .= "<label>Mobile Number </label> <input type='text' style='width:400px;' name='testmobile'>";
$content .= "<br><input type='submit'class='elgg-button elgg-button-action' name='submit'></form>";
} elseif ($step == '4') {
// echo $group->whatsapp_mobile."".$group->whatsapp_password;
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->connect();
$wa->loginWithPassword($group->whatsapp_password);
// $wa->sendSetProfilePicture($group->getIconURL());
$wa->sendMessage($_POST['testmobile'], "You have done it,Visit http://enraiser.com visit http://Kindit.org ");
示例7: strtolower
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
include '../lib/whatsprot.class.php';
$login = mysql_real_escape_string($_POST['newUser']);
$phone = mysql_real_escape_string($_POST['newPhone']);
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>";
示例8: trim
}
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 > ";
$right = trim(fgets(STDIN));
if ($right != 'yes') {
echo "\nYour nickname > ";
$nickname = trim(fgets(STDIN));
}
} while ($right != 'yes');
$db = new \PDO("sqlite:" . $fileName, null, null, array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));