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: '******'</>'); } 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 . '</>'); }
* - 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.
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'] : ''; } }
} 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 > '; $right = trim(fgets(STDIN)); if ($right != 'yes') { echo "\nYour nickname > "; $nickname = trim(fgets(STDIN)); } } while ($right != 'yes'); $fp = fopen($fileName, 'c');
<?php session_start(); // require_once('lib/whatsApi/whatsprot.class.php'); require_once 'lib/whatsApi/Registration.php'; if (isset($_GET['code']) && !is_null($_GET['code'])) { $celular = "55" . $_SESSION['celular']; $debug = true; $w = new Registration($celular, $debug); // $fWhats = file_get_contents("whatsregister.dat"); // $w = unserialize($fWhats); try { $code = str_replace("-", "", $_GET['code']); $result = $w->codeRegister(trim($code)); } catch (Exception $e) { echo $e->getMessage(); exit(0); } $fp = @fopen("user_config.php", "a+"); if ($fp) { fwrite($fp, '$password = "******"' . ";\n"); fclose($fp); echo "OK"; 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): ";
<?php /** * Created by PhpStorm. * User: seeb * Date: 29.12.15 * Time: 23:16 * * @see https://github.com/WHAnonymous/Chat-API/wiki/WhatsAPI-Documentation#sending-messages */ use Thomblin\Whatsapp\Db\Pdo; use Thomblin\Whatsapp\Repository\Credentials; require_once __DIR__ . '/../../vendor/autoload.php'; $username = readline("Enter whatsapp phone number (with region code, like 49178123456): "); $r = new Registration($username); $r->codeRequest('sms'); $smsCode = readline("You got a sms. Enter provided code (number): "); $response = $r->codeRegister($smsCode); if (isset($response->pw)) { $nickname = readline("Enter a nickname for your account: "); $credentials = new Credentials(Pdo::createInstance()); $credentials->addCredential(new \Thomblin\Whatsapp\Db\Model\Credential(['protocol' => Credentials::PROTOCOL_WHATSAPP, 'username' => $username, 'nickname' => $nickname, 'password' => $response->pw])); echo "Registration completed\n"; } else { echo "\n Registration was NOT successful. Please check response and documentation! response: \n"; print_r($response); exit(1); } 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('317926'); // 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.