function testParsing() { $request = new Uri_Parser('/search.xml?user=brenda'); $this->assertEqual($request->get_method(), 'search'); $this->assertEqual($request->get_format(), 'xml'); $param = $request->get_params(); $this->assertEqual($param['user'], 'brenda'); $this->assertEqual(sizeof($param), 1); $request = new Uri_Parser('/wrms.request.get_request.xml?user=brenda'); $this->assertEqual($request->get_method(), 'wrms_request_get_request'); $this->assertEqual($request->get_format(), 'xml'); $param = $request->get_params(); $this->assertEqual($param['user'], 'brenda'); $this->assertEqual(sizeof($param), 1); }
* - @link /api/constants Constants @endlink * - @link /api/globals Global variables @endlink * */ /** * @file * Every request goes through this file * * e.g. http://api.wrms.com/wrms.get * */ require_once 'medusa/common.php'; $params = array('GET' => array(), 'POST' => array()); $uri = $_SERVER['REQUEST_URI']; $Uri_Parser = new Uri_Parser($uri); $method = $Uri_Parser->get_method(); $params['GET'] = $Uri_Parser->get_params(); $format = $Uri_Parser->get_format(); $response_renderer = response_renderer::getInstance(); error_logging('DEBUG', "method={$method} params=" . print_r($params, true) . " format={$format}"); /* * POST variables are not cleaned here */ #foreach ($_POST as $k => $v) { $params['POST'] = $_POST; #} if (!$method) { error_logging('ERROR', "No method"); echo $response_renderer->render(new error("Method required")); exit(0); } elseif (!$format) {