$request_url, CURLOPT_HTTPHEADER => $headers, CURLOPT_USERPWD => $username . ":" . $password, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYHOST => true, //hack-ish demo options CURLOPT_SSL_VERIFYPEER => 0 )); // check if we got a response, if not throw a 501 and print a json // readable error message. $response = curl_exec($ch); if ($response === false) { $msg = "{error: '" . curl_error($ch) . "(" . $response . ")'}\n"; http_response_code(501); header("Content-Type: application/json", true); header("Content-length: " . strlen($msg)); // prevent chuncked encoding echo $msg; exit(1); } // if we got this far, we got a valid response from the server $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo $response; ?>