summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/api.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/http/api.php b/http/api.php
index a3f155d..29c56ec 100644
--- a/http/api.php
+++ b/http/api.php
@@ -28,6 +28,18 @@ Parametry:
*/
+if (!function_exists('http_response_code')) {
+ function http_response_code($code = NULL) {
+ $codes = array(400 => "Bad Request",
+ 500 => "Internal Server Error");
+ if (!isset($codes[$code])) {
+ return;
+ }
+ $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
+ header($protocol . ' ' . $code . ' ' . $codes[$code]);
+ }
+}
+
class ParametersException extends Exception {};
function safe_ceil($value, $precision = 1e-6) {
@@ -201,12 +213,7 @@ function run($parameters) {
}
}
-/*if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- http_response_code(405);
- die('API only accepts POST requests');
-} else {*/
- header('Content-Type: application/json');
- print(json_encode(run($_REQUEST)));
-//}
+header('Content-Type: application/json');
+print(json_encode(run($_REQUEST)));
?>