function HTTP_GET() { $json = new paloSantoJSON(); $pCore_calendar = new core_Calendar(); $fields = isset($_GET["fields"]) ? $_GET["fields"] : NULL; if (is_null($fields)) { header("HTTP/1.1 400 Bad Request"); $error = "You need to specify by GET the parameter \"fields\""; $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } $result = $pCore_calendar->getHash($fields); if ($result === FALSE) { $error = $pCore_calendar->getError(); if ($error["fc"] == "DBERROR") { header("HTTP/1.1 500 Internal Server Error"); } else { header("HTTP/1.1 400 Bad Request"); } $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } else { $json = new Services_JSON(); return $json->encode($result); } }
function HTTP_GET() { $json = new paloSantoJSON(); $pCore_calendar = new core_Calendar(); $result = $pCore_calendar->getFullSync(); if ($result === FALSE) { $error = $pCore_calendar->getError(); if ($error["fc"] == "DBERROR") { header("HTTP/1.1 500 Internal Server Error"); } else { header("HTTP/1.1 400 Bad Request"); } $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } else { $json = new Services_JSON(); return $json->encode($result); } }
function HTTP_DELETE() { $pCore_Calendar = new core_Calendar(); $json = new paloSantoJSON(); $result = $pCore_Calendar->delCalendarEvent($this->_idNumero); if ($result === FALSE) { $error = $pCore_Calendar->getError(); if ($error["fc"] == "DBERROR") { header("HTTP/1.1 500 Internal Server Error"); } elseif ($error['fc'] == 'ADDRESSBOOK') { header("HTTP/1.1 404 Not Found"); } else { header("HTTP/1.1 400 Bad Request"); } $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } else { $json = new Services_JSON(); $response["message"] = "The event was successfully deleted"; return $json->encode($response); } }
function HTTP_GET() { $pCore_AddressBook = new core_AddressBook(); $image = $pCore_AddressBook->getContactImage($this->_idNumero, $this->_thumbnail); if ($image === FALSE) { $json = new paloSantoJSON(); $error = $pCore_AddressBook->getError(); if ($error["fc"] == "DBERROR") { header("HTTP/1.1 500 Internal Server Error"); } else { header("HTTP/1.1 400 Bad Request"); } $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } else { return $image; } }
$Id: rest.php,v 1.1 2012/02/07 23:49:36 Alberto Santos Exp $ */ global $arrConf; $documentRoot = $_SERVER["DOCUMENT_ROOT"]; require_once "{$documentRoot}/libs/misc.lib.php"; require_once "{$documentRoot}/configs/default.conf.php"; require_once "{$documentRoot}/libs/paloSantoJSON.class.php"; require_once "{$documentRoot}/libs/paloSantoACL.class.php"; load_default_timezone(); // Verificación de autenticación // Verificar si el método HTTP es conocido if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'POST', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'))) { Header('HTTP/1.1 501 Not Implemented'); exit; } $json = new paloSantoJSON(); header('Content-Type: application/json'); /***********************User authentication********************************/ if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] == '') { header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Basic realm="ElastixWebService"'); $json->set_status("ERROR"); $json->set_error("This method requires authentication"); echo $json->createJSON(); exit; } $pACL = new paloACL($arrConf['elastix_dsn']['acl']); if (!empty($pACL->errMsg)) { header("HTTP/1.1 500 Internal Server Error"); $json->set_status("ERROR"); $json->set_error("Unable to authenticate due to DB error: " . $pACL->errMsg);