src/Registration.php
protected function getResponse($host, $query)
  {
      // Build the url.
      $url = $host.'?'.http_build_query($query);

      // Open connection.
      $ch = curl_init();

      // Configure the connection.
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_USERAGENT, Constants::WHATSAPP_USER_AGENT);
      curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept: text/json']);
      // This makes CURL accept any peer!
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

      // Get the response.
      $response = curl_exec($ch);

      // Close the connection.
      curl_close($ch);

      return json_decode($response);
  }
protected function getResponse($host, $query)
  {
      // Build the url.
      $url = $host.'?'.http_build_query($query);

      // Open connection.
      $ch = curl_init();

      // Configure the connection.
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_USERAGENT, Constants::WHATSAPP_USER_AGENT);
      curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept: text/json']);
      // This makes CURL accept any peer!
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

      // Get the response.
      $response = curl_exec($ch);

      // Close the connection.
      curl_close($ch);

      return json_decode($response);
  }
protected function getResponse ( $ host , $ query ) { // Build the url. $ url = $ host . '?' . http_build_query ( $ query ) ; // Open connection. $ ch = curl_init ( ) ; // Configure the connection. curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , Constants :: WHATSAPP_USER_AGENT ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , [ 'Accept: text/json' ] ) ; // This makes CURL accept any peer! curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; // Get the response. $ response = curl_exec ( $ ch ) ; // Close the connection. curl_close ( $ ch ) ; return json_decode ( $ response ) ; }
Get a decoded JSON response from Whatsapp server.

@param  string $host  The host URL
@param  array  $query A associative array of keys and values to send to server.

@return null|object   NULL if the json cannot be decoded or if the encoded data is deeper than the recursion limit
Get a decoded JSON response from Whatsapp server .