public function sendRequest($action, $query, $type = 'GET') { $result = ""; $request_url = self::$path . '?action=' . $action; if ($query != NULL) { $json_query = json_encode($query); $request_url .= '&query=' . urlencode($json_query); } $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $request_url); if ($type == 'GET') { curl_setopt($curl_handle, CURLOPT_HTTPGET, 1); } // prevent output of response contents to STDOUT curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); // prevent self-signed SSL certificate errors. Remove in production environments. curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, 0); // set authentication headers curl_setopt($curl_handle, CURLOPT_HTTPHEADER, VolunteerMatchAPI::getHTTPHeadersForAuthenticationRequest()); if (!($response = curl_exec($curl_handle))) { $error = self::$errorMap["http_" . $httpStatus]; self::$errorMessage = $error ? $error : self::$defaultError; } else { self::$responseBody = $response; } self::$responseCode = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); curl_close($curl_handle); }