Ejemplo n.º 1
1
 /**
  * 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());
     }
 }
Ejemplo n.º 2
0
 /** 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;
 }
Ejemplo n.º 3
0
 /**
  * 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;
     }
 }
Ejemplo n.º 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);
}
Ejemplo n.º 5
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.
Ejemplo n.º 6
0
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);
}
Ejemplo n.º 7
0
     $content .= "<form method='post' action='" . elgg_get_site_url() . "enriver/setup/whatsapp/{$segments['2']}/2'>";
     $content .= "<br><table><tr><td><label>Mobile Number&nbsp</label></td><td><input type='text' style='width:400px;'name='mobile'></td></tr>";
     $content .= "<tr><td><label>IMEI&nbsp</label></td><td><input type='text' style='width:400px; name='imei'></td></tr>";
     $content .= "<tr><td><label>Nick Name&nbsp</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();
Ejemplo n.º 8
0
    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 > ";