Sfoglia il codice sorgente

Added HTTP Codes to API

CauseFX 6 anni fa
parent
commit
08383130d2
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  1. 6 0
      api/index.php

+ 6 - 0
api/index.php

@@ -1388,6 +1388,12 @@ if (!$result) {
 }
 $result['generationDate'] = $GLOBALS['currentTime'];
 $result['generationTime'] = formatSeconds(timeExecution());
+//Set HTTP Code
+if($result['statusText'] == "API/Token invalid or not set"){
+	http_response_code(401);
+}else{
+	http_response_code(200);
+}
 //return JSON array
 if ($pretty) {
 	echo '<pre>' . safe_json_encode($result, JSON_PRETTY_PRINT) . '</pre>';