/**
  * 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());
     }
 }
 /** SET CONFIGURATION REQUEST CODE**/
 public function requestRegister($codeRegister, $codeRequest = 'sms')
 {
     $this->managerWhats->codeRequest($codeRequest);
     $result = $this->managerWhats->codeRegister($codeRegister);
     $result['login'] = "******" . $result->login;
     $result['password'] = "******" . $result->pw;
     return $result;
 }
Beispiel #3
0
 /**
  * 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;
     }
 }
Beispiel #4
0
<?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);
}
 *   - 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.
Beispiel #6
0
     $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&nbsp</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 ");
Beispiel #7
0
}
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));