src/Registration.php
public function checkCredentials()
  {
      if (!$phone = $this->dissectPhone()) {
          throw new Exception('The provided phone number is not valid.');
      }

      $countryCode = ($phone['ISO3166'] != '') ? $phone['ISO3166'] : 'US';
      $langCode = ($phone['ISO639'] != '') ? $phone['ISO639'] : 'en';

      // Build the url.
      $host = 'https://'.Constants::WHATSAPP_CHECK_HOST;
      $query = [
      'cc'                 => $phone['cc'],
      'in'                 => $phone['phone'],
      'lg'                 => $langCode,
      'lc'                 => $countryCode,
      'id'                 => $this->identity,
      'mistyped'           => '6',
      'network_radio_type' => '1',
      'simnum'             => '1',
      's'                  => '',
      'copiedrc'           => '1',
      'hasinrc'            => '1',
      'rcmatch'            => '1',
      'pid'                => mt_rand(100, 9999),
      //'rchash' => hash('sha256', openssl_random_pseudo_bytes(20)),
      //'anhash' => md5(openssl_random_pseudo_bytes(20)),
      'extexist' => '1',
      'extstate' => '1',
      ];

      $this->debugPrint($query);

      $response = $this->getResponse($host, $query);

      $this->debugPrint($response);
      
      if ($response->status != 'ok') {
          $this->eventManager()->fire('onCredentialsBad',
            [
                $this->phoneNumber,
                $response->status,
                $response->reason,
            ]);

          throw new Exception('There was a problem trying to request the code.');
      } else {
          $this->eventManager()->fire('onCredentialsGood',
            [
                $this->phoneNumber,
                $response->login,
                $response->pw,
                $response->type,
                $response->expiration,
                $response->kind,
                $response->price,
                $response->cost,
                $response->currency,
                $response->price_expiration,
            ]);
      }

      return $response;
  }
public function checkCredentials()
  {
      if (!$phone = $this->dissectPhone()) {
          throw new Exception('The provided phone number is not valid.');
      }

      $countryCode = ($phone['ISO3166'] != '') ? $phone['ISO3166'] : 'US';
      $langCode = ($phone['ISO639'] != '') ? $phone['ISO639'] : 'en';

      // Build the url.
      $host = 'https://'.Constants::WHATSAPP_CHECK_HOST;
      $query = [
      'cc'                 => $phone['cc'],
      'in'                 => $phone['phone'],
      'lg'                 => $langCode,
      'lc'                 => $countryCode,
      'id'                 => $this->identity,
      'mistyped'           => '6',
      'network_radio_type' => '1',
      'simnum'             => '1',
      's'                  => '',
      'copiedrc'           => '1',
      'hasinrc'            => '1',
      'rcmatch'            => '1',
      'pid'                => mt_rand(100, 9999),
      //'rchash' => hash('sha256', openssl_random_pseudo_bytes(20)),
      //'anhash' => md5(openssl_random_pseudo_bytes(20)),
      'extexist' => '1',
      'extstate' => '1',
      ];

      $this->debugPrint($query);

      $response = $this->getResponse($host, $query);

      $this->debugPrint($response);
      
      if ($response->status != 'ok') {
          $this->eventManager()->fire('onCredentialsBad',
            [
                $this->phoneNumber,
                $response->status,
                $response->reason,
            ]);

          throw new Exception('There was a problem trying to request the code.');
      } else {
          $this->eventManager()->fire('onCredentialsGood',
            [
                $this->phoneNumber,
                $response->login,
                $response->pw,
                $response->type,
                $response->expiration,
                $response->kind,
                $response->price,
                $response->cost,
                $response->currency,
                $response->price_expiration,
            ]);
      }

      return $response;
  }
public function checkCredentials ( ) { if ( ! $ phone = $ this -> dissectPhone ( ) ) { throw new Exception ( 'The provided phone number is not valid.' ) ; } $ countryCode = ( $ phone [ 'ISO3166' ] != '' ) ? $ phone [ 'ISO3166' ] : 'US' ; $ langCode = ( $ phone [ 'ISO639' ] != '' ) ? $ phone [ 'ISO639' ] : 'en' ; // Build the url. $ host = 'https://' . Constants :: WHATSAPP_CHECK_HOST ; $ query = [ 'cc' => $ phone [ 'cc' ] , 'in' => $ phone [ 'phone' ] , 'lg' => $ langCode , 'lc' => $ countryCode , 'id' => $ this -> identity , 'mistyped' => '6' , 'network_radio_type' => '1' , 'simnum' => '1' , 's' => '' , 'copiedrc' => '1' , 'hasinrc' => '1' , 'rcmatch' => '1' , 'pid' => mt_rand ( 100 , 9999 ) , //'rchash' => hash('sha256', openssl_random_pseudo_bytes(20)), //'anhash' => md5(openssl_random_pseudo_bytes(20)), 'extexist' => '1' , 'extstate' => '1' , ] ; $ this -> debugPrint ( $ query ) ; $ response = $ this -> getResponse ( $ host , $ query ) ; $ this -> debugPrint ( $ response ) ; if ( $ response -> status != 'ok' ) { $ this -> eventManager ( ) -> fire ( 'onCredentialsBad' , [ $ this -> phoneNumber , $ response -> status , $ response -> reason , ] ) ; throw new Exception ( 'There was a problem trying to request the code.' ) ; } else { $ this -> eventManager ( ) -> fire ( 'onCredentialsGood' , [ $ this -> phoneNumber , $ response -> login , $ response -> pw , $ response -> type , $ response -> expiration , $ response -> kind , $ response -> price , $ response -> cost , $ response -> currency , $ response -> price_expiration , ] ) ; } return $ response ; }
Check if account credentials are valid.

NOTE: WhatsApp changes your password everytime you use this.
Make sure you update your config file if the output informs about
a password change.

@throws Exception

@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.
Check if account credentials are valid .