24 require_once(
"bootstrap.php");
36 static $srcPathList = array();
46 $srcPathList[
"standard"] =
"/usr/share/php";
49 $includePathList = explode(PATH_SEPARATOR, get_include_path());
51 foreach ($srcPathList as $path) {
52 if (!in_array($path, $includePathList)) {
53 $includePathList[] = $path;
57 $finalIncludePathList = array_reverse($includePathList);
60 set_include_path(implode(PATH_SEPARATOR, $finalIncludePathList));
64 if (preg_match(
"/_/", $class_name)) {
65 $file_name = str_replace(
'_', DIRECTORY_SEPARATOR, $class_name) .
'.php';
68 }
else if (preg_match(
"/\\/", $class_name)) {
69 $file_name = str_replace(
'\\', DIRECTORY_SEPARATOR, ltrim($class_name,
'\\')) .
'.php';
73 $file_name = $class_name .
'.php';
77 foreach ($srcPathList as $namespace => $path) {
78 $file_path = $path . DIRECTORY_SEPARATOR . $file_name;
79 if (is_file($file_path) && is_readable($file_path)) {
91 $options[
"databaseAdapter"] =
$dbh;
92 $options[
"loginAdapterList"] = array(
"sharedsecret",
"login");
95 $data[
"token_hash"] = $token;
98 $response = $service->call(
102 header(
"Content-Type: application/json");
103 echo $response->toJson();
105 }
catch (Exception $e) {
108 header(
"Content-Type: application/json");
109 $response =
new Alternc_Api_Response(array(
"code" => $e->getCode(),
"message" => $e->getMessage()));
110 echo $response->toJson();
117 $options[
"databaseAdapter"] =
$dbh;
121 $response = $service->auth($data);
122 header(
"Content-Type: application/json");
123 echo $response->toJson();
125 }
catch (Exception $e) {
128 header(
"Content-Type: application/json");
130 echo $response->toJson();
141 if (preg_match(
"#^/api/auth/([^/\?]*)[/\?]?#", $_SERVER[
"REQUEST_URI"], $mat)) {
142 if ($_SERVER[
"REQUEST_METHOD"] ==
"POST") {
143 $data = array(
"options" => $_POST,
144 "method" => $mat[1]);
148 $data = array(
"options" => $_GET,
149 "method" => $mat[1]);
156 if ($_SERVER[
"REQUEST_URI"] ==
"/api/post") {
158 if ($_SERVER[
"REQUEST_METHOD"] ==
"POST") {
159 $data = array(
"options" => $_POST,
160 "object" => $_POST[
"object"],
161 "action" => $_POST[
"action"],
163 $token = $_POST[
"token"];
167 $data = array(
"options" => $_GET,
168 "object" => $_GET[
"object"],
169 "action" => $_GET[
"action"],
171 $token = $_GET[
"token"];
176 if (preg_match(
"#^/api/rest/([^/]*)/([^/\?]*)[/\?]?#", $_SERVER[
"REQUEST_URI"], $mat)) {
177 if ($_SERVER[
"REQUEST_METHOD"] ==
"POST") {
178 $data = array(
"options" => $_POST,
182 $token = $_POST[
"token"];
186 $data = array(
"options" => $_GET,
190 $token = $_GET[
"token"];
196 echo
"I did nothing. Did you call the api properly?";
__autoload($class_name)
multiple call-mode API for Alternc you can call this HTTP(s) API as follow: from the base url https:/...
Standard Request object for the AlternC API.
Standard Response object for the AlternC API.
Service API used by server to export API methods this class can be used to implement an API service /...