src/HipChat/HipChat.php
public function make_request($api_method, $args = array(),
                               $http_method = 'GET') {
    $args['format'] = 'json';
    $args['auth_token'] = $this->auth_token;
    $url = "$this->api_target/$this->api_version/$api_method";
    $post_data = null;

    // add args to url for GET
    if ($http_method == 'GET') {
      $url .= '?' . http_build_query($args);
    } else {
      $post_data = $args;
    }

    $response = $this->curl_request($url, $post_data);

    // make sure response is valid json
    $response = json_decode($response);
    if (!$response) {
      throw new HipChat_Exception(self::STATUS_BAD_RESPONSE,
        "Invalid JSON received: $response", $url);
    }

    return $response;
  }
public function make_request($api_method, $args = array(),
                               $http_method = 'GET') {
    $args['format'] = 'json';
    $args['auth_token'] = $this->auth_token;
    $url = "$this->api_target/$this->api_version/$api_method";
    $post_data = null;

    // add args to url for GET
    if ($http_method == 'GET') {
      $url .= '?' . http_build_query($args);
    } else {
      $post_data = $args;
    }

    $response = $this->curl_request($url, $post_data);

    // make sure response is valid json
    $response = json_decode($response);
    if (!$response) {
      throw new HipChat_Exception(self::STATUS_BAD_RESPONSE,
        "Invalid JSON received: $response", $url);
    }

    return $response;
  }
public function make_request ( $ api_method , $ args = array ( ) , $ http_method = 'GET' ) { $ args [ 'format' ] = 'json' ; $ args [ 'auth_token' ] = $ this -> auth_token ; $ url = "$this->api_target/$this->api_version/$api_method" ; $ post_data = null ; // add args to url for GET if ( $ http_method == 'GET' ) { $ url .= '?' . http_build_query ( $ args ) ; } else { $ post_data = $ args ; } $ response = $ this -> curl_request ( $ url , $ post_data ) ; // make sure response is valid json $ response = json_decode ( $ response ) ; if ( ! $ response ) { throw new HipChat_Exception ( self :: STATUS_BAD_RESPONSE , "Invalid JSON received: $response" , $ url ) ; } return $ response ; }
Make an API request using curl

@param string $api_method  Which API method to hit, like 'rooms/show'.
@param array  $args        Data to send.
@param string $http_method HTTP method (GET or POST).

@throws HipChat_Exception
@return mixed
Make an API request using curl