private static function execRequest($httpMethod, $url, $parameters, $authHandlers, $contentType, $encodeJson) { // first, collect the headers and parameters we'll need from the authentication handlers list($headers, $authParameters) = HttpUtils::handleAuthentication($authHandlers); if (is_array($parameters)) { $parameters = array_merge($parameters, $authParameters); } // prepare the request $ch = curl_init(); if ($httpMethod == HttpMethod::GET) { $url = UrlUtils::buildUrlWithQueryString($url, $parameters); } else { $data = HttpUtils::buildDataForContentType($contentType, $parameters, $headers); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); if (curl_error($ch)) { throw new MashapeClientException(EXCEPTION_CURL . ":" . curl_error($ch), EXCEPTION_CURL_CODE); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $responseHeaders = curl_getinfo($ch, CURLINFO_HEADER_OUT); curl_close($ch); return new MashapeResponse($response, $httpCode, $responseHeaders, $encodeJson); }