public static function processRequest() { // get our verb $request_method = strtolower($_SERVER['REQUEST_METHOD']); $return_obj = new RestRequest(); // we'll store our data here $data = array(); // only POST is available switch ($request_method) { case 'post': $data = $_POST; 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['service'])) { // translate the JSON to an Object for use however you want $return_obj->setService($data['service']); } if (isset($data['text'])) { $return_obj->setTextToProc($data['text']); } return $return_obj; }