function response($data, $status = 200) { header("HTTP/1.1 " . $status . " " . _requestStatus($status)); return json_encode($data); }
function _sendData($data = array(), $status = 200, $onlyFirst = false) { // headers for not caching the results header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // allow all requests header("Access-Control-Allow-Orgin: http://farseer.de"); header("Access-Control-Allow-Methods: *"); // headers to tell that result is JSON header('Content-type: application/json'); //send status header("HTTP/1.1 " . $status . " " . _requestStatus($status)); // send the result now if ($onlyFirst && !empty($data)) { echo json_encode($data[0]); } else { echo json_encode($data); } //end script exit; }