function processRequest() { if (isset($_SERVER['REQUEST_METHOD'])) { $request_method = strtolower($_SERVER['REQUEST_METHOD']); } else { $request_method = "get"; } $return_obj = new RestRequest(); $data = array(); switch ($request_method) { // gets are easy... case 'get': $data = $_GET; if (isset($_SERVER['REQUEST_METHOD'])) { $return_obj->setRURI($_SERVER['REQUEST_URI']); } break; case 'post': $data = $_POST; if (isset($_SERVER['REQUEST_METHOD'])) { $return_obj->setRURI($_SERVER['REQUEST_URI']); } break; case 'delete': $data = $_GET; if (isset($_SERVER['REQUEST_METHOD'])) { $return_obj->setRURI($_SERVER['REQUEST_URI']); } break; // here's the tricky bit... // here's the tricky bit... case 'put': parse_str(file_get_contents('php://input'), $put_vars); $data = $put_vars; break; } // store the method $return_obj->setMethod($request_method); // set the raw data, so we can access it if needed (there may be // other pieces to your requests) $return_obj->setRequestVars($data); if (isset($data['data'])) { // translate the JSON to an Object for use however you want $return_obj->setData(json_decode($data['data'])); } return $return_obj; }