hostname = $_SERVER['HTTP_HOST']; $rqst->path = '/wellrested/samples/server-side-response.php'; // Issue the request, and read the response returned by the server. try { $resp = $rqst->request(); } catch (CurlException $e) { // Explain the cURL error and provide an error status code. $myResponse = new Response(); $myResponse->statusCode = 500; $myResponse->setHeader('Content-Type', 'text/plain'); $myResponse->body = 'Message: ' .$e->getMessage() ."\n"; $myResponse->body .= 'Code: ' . $e->getCode() . "\n"; $myResponse->respond(); exit; } // Create new response to send to output to the browser. $myResponse = new Response(); $myResponse->statusCode = 200; $myResponse->setHeader('Content-Type', 'application/json'); $json = array( 'Status Code' => $resp->statusCode, 'Body' => $resp->body, 'Headers' => $resp->headers ); $myResponse->body = json_encode($json); $myResponse->respond(); exit;