diff options
author | emkael <emkael@tlen.pl> | 2019-02-14 12:45:39 +0300 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-02-14 12:45:39 +0300 |
commit | af780009430cf5b1b511cf2b75479fd072d391cd (patch) | |
tree | a134aa8b804e6f08ceeac5d46dd17720e5448a4e | |
parent | ef4974082b40d59e631174ca694dc3fbd50f8fae (diff) |
This is ridiculous.
-rw-r--r-- | http/api.php | 21 |
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))); ?> |