1
0
mirror of https://gitlab.com/JKANetwork/CheckServer.git synced 2026-02-14 17:21:35 +01:00

Test JSON API check

This commit is contained in:
2018-01-16 09:36:53 +01:00
parent 84cb21dcf3
commit 635a223538

View File

@@ -39,7 +39,6 @@ function DATABASE_CONN($ID_C,$URL){
}
}
//WIP, doesnt compare right!
function JSON_API($ID_C,$URL,$params,$exceptedRes){
$type = explode('|',$params)[0];
$JSONParams = explode('|',$params)[1];
@@ -48,10 +47,10 @@ function JSON_API($ID_C,$URL,$params,$exceptedRes){
if ($type == 'GET'){
curl_setopt($ch, CURLOPT_URL, $URL . $JSONParams);
}else if ($type == 'POST'){
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $JSONParams);
}
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 4); //timeout in seconds
@@ -60,9 +59,7 @@ function JSON_API($ID_C,$URL,$params,$exceptedRes){
$json_ret = json_decode($body,true);
$json_param = json_decode($exceptedRes,true);
$comp_ret =serialize($json_ret);
$comp_param =serialize($json_param);
if ($comp_ret == $comp_param){
if ($json_ret == $json_param){
return 0;
}else{
return 1;