Ejemplo n.º 1
0
 /**
  * Check if account credentials are valid.
  *
  * WARNING: WhatsApp now changes your password everytime you use this.
  * Make sure you update your config file if the output informs about
  * a password change.
  *
  * @param  Identity $identity
  * @return array
  *                           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.
  *
  * @throws \RuntimeException
  */
 public function checkCredentials(Identity $identity)
 {
     $host = 'https://' . Client::WHATSAPP_CHECK_HOST;
     $query = ['cc' => $identity->getPhone()->getCc(), 'in' => $identity->getPhone()->getPhoneNumber(), 'id' => $identity->getIdentityString(), 'lg' => $identity->getPhone()->getIso639() ?: 'en', 'lc' => $identity->getPhone()->getIso3166() ?: 'US', 'network_radio_type' => "1"];
     $response = $this->getResponse($host, $query);
     if ($response['status'] != 'ok') {
         $message = 'There was a problem trying to request the code. ' . $response['reason'];
         throw new \RuntimeException($message);
     }
     return $response;
 }