Example #1
0
 /**
  * Helper method for making a OAuth 2.0 request
  *
  * @param string the URL path on the server
  * @param array this optional associative array will be used as url-encoded POST content.
  * @return array JSON response
  */
 public function query_api($path, array $data = null)
 {
     $data = is_null($data) ? "" : http_build_query($data);
     $headers = array("Authorization" => "Basic " . base64_encode($this->client_id . ":" . $this->client_secret), "Content-Type" => "application/x-www-form-urlencoded", "Content-Length" => strlen($data));
     $request = new HttpsRequest();
     return $request->request($path, $data, "POST", $headers);
 }
Example #2
0
 /**
  * Helper method for making a REST request
  *
  * @param string the URL path on the server
  * @param array this optional associative array will be used as JSON-encoded POST content.
  * @param string the HTTP method
  * @return array JSON response
  */
 public function query_api($path, array $data = null, $method = "GET")
 {
     $data = is_null($data) ? "" : json_encode($data);
     $headers = array("Authorization" => "Bearer " . $this->access_token, "Content-Type" => "application/json", "Content-Length" => strlen($data));
     $request = new HttpsRequest();
     return $request->request($path, $data, $method, $headers);
 }