X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..05ce1c11e98b33f14ddee184493bd5a60dc947e2:/examples/restful/remote/lib/request.php diff --git a/examples/restful/remote/lib/request.php b/examples/restful/remote/lib/request.php index 60c1df21..8d506623 100644 --- a/examples/restful/remote/lib/request.php +++ b/examples/restful/remote/lib/request.php @@ -24,12 +24,29 @@ class Request { fclose($httpContent); $params = array(); parse_str($raw, $params); - $this->id = (isset($params['id'])) ? $params['id'] : null; - $this->params = (isset($params['data'])) ? json_decode(stripslashes($params['data']), true) : null; + + if (isset($params['data'])) { + $this->params = json_decode(stripslashes($params['data'])); + } else { + $params = json_decode(stripslashes($raw)); + $this->params = $params->data; + } } else { // grab JSON data if there... - $this->params = (isset($_REQUEST['data'])) ? json_decode(stripslashes($_REQUEST['data']), true) : null; - $this->id = (isset($_REQUEST['id'])) ? json_decode(stripslashes($_REQUEST['id']), true) : null; + $this->params = (isset($_REQUEST['data'])) ? json_decode(stripslashes($_REQUEST['data'])) : null; + + if (isset($_REQUEST['data'])) { + $this->params = json_decode(stripslashes($_REQUEST['data'])); + } else { + $raw = ''; + $httpContent = fopen('php://input', 'r'); + while ($kb = fread($httpContent, 1024)) { + $raw .= $kb; + } + $params = json_decode(stripslashes($raw)); + $this->params = $params->data; + } + } // Quickndirty PATH_INFO parser if (isset($_SERVER["PATH_INFO"])){