Backend Service
This commit is contained in:
@@ -38,6 +38,16 @@ if (array_search($_SERVER['REQUEST_METHOD'], $methods) === false) {
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
if ($endpoint == "uploadfile") {
|
||||||
|
upload_file_call();
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
$raw_json = file_get_contents("php://input");
|
||||||
|
$raw_array = json_decode($raw_json, true);
|
||||||
|
$in = flatten($raw_array);
|
||||||
|
}
|
||||||
|
}
|
||||||
// $in["action"] = MERMS_USER_CREATEACCOUNT;
|
// $in["action"] = MERMS_USER_CREATEACCOUNT;
|
||||||
$in["loc"] = $_SERVER["REMOTE_ADDR"];
|
$in["loc"] = $_SERVER["REMOTE_ADDR"];
|
||||||
|
|
||||||
@@ -45,8 +55,8 @@ switch ($endpoint) {
|
|||||||
case 'userlogin':
|
case 'userlogin':
|
||||||
case 'login':
|
case 'login':
|
||||||
$in["action"] = MERMS_USER_LOGIN;
|
$in["action"] = MERMS_USER_LOGIN;
|
||||||
$in["account_no"] = "7702222222";
|
//$in["account_no"] = "7702222222";
|
||||||
$in["password"] = "1234";
|
//$in["password"] = "1234";
|
||||||
break;
|
break;
|
||||||
case 'createuser':
|
case 'createuser':
|
||||||
$in["action"] = MERMS_USER_CREATEACCOUNT;
|
$in["action"] = MERMS_USER_CREATEACCOUNT;
|
||||||
@@ -101,12 +111,28 @@ switch ( $in["action"] ) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calling the backend
|
||||||
|
$out["internal_return"]= $mermsemr->mermsemr_api($in,$out);
|
||||||
|
|
||||||
|
|
||||||
header("HTTP/1.1 200 OK");
|
header("HTTP/1.1 200 OK");
|
||||||
header("Status: 200 OK");
|
header("Status: 200 OK");
|
||||||
//$out = array_merge($in, $out); // DEBUG
|
//$out = array_merge($in, $out); // DEBUG
|
||||||
echo json_encode(processOutJson($in, $out));
|
echo json_encode(processOutJson($in, $out));
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
|
function flatten($data, $parentkey = "") {
|
||||||
|
$result = array();
|
||||||
|
foreach ($data as $key => $val) {
|
||||||
|
if (is_array($val)) {
|
||||||
|
$result = array_merge($result, flatten($val, $parentkey . $key . "_"));
|
||||||
|
} else {
|
||||||
|
$result[$parentkey . $key] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
function processOutJson($in, $out) {
|
function processOutJson($in, $out) {
|
||||||
switch ($in["action"]) {
|
switch ($in["action"]) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user