X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/examples/restful/remote/lib/request.php?ds=sidebyside diff --git a/examples/restful/remote/lib/request.php b/examples/restful/remote/lib/request.php index 60c1df21..bb8461e6 100644 --- a/examples/restful/remote/lib/request.php +++ b/examples/restful/remote/lib/request.php @@ -24,12 +24,31 @@ 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; + } } 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)); + if ($params) { + $this->params = $params; + } + } + } // Quickndirty PATH_INFO parser if (isset($_SERVER["PATH_INFO"])){