public function test($format = null) { global $request; if (isset($request[1])) { switch ($request[1]) { case 'all': $rs = $this->getAllwp_terms(); break; case 'count': $rs = $this->count(); break; case 'page': if (isset($request[2]) && isset($request[3]) && is_numeric($request[2]) && is_numeric($request[3])) { $rs = $this->getUsers_paged($request[2], $request[3]); } else { $rs = $this->getUsers_paged(0, 20); } break; case $request[1]: $rs = $this->getwp_termsByID($request[1]); break; default: // $rs = $this->getwp_terms_paged(0,5); // $rs = $this->deletewp_terms(1); break; } } else { $rs = $this->getAllwp_terms(); } if ($format) { if ($format == 'json') { header("Content-type: text/json; charset=utf-8"); echo json_encode($rs); } else { if ($format == 'xml') { header("Content-type: text/xml; charset=utf-8"); $js = json_encode($rs); $arjs = json_decode($js, true); echo Pdoconfig::arrayToXml($arjs, '<XML></XML>'); } } } else { var_dump($rs); } }
$app->response()->status(404); $app->response()->header('X-Status-Reason', $e->getMessage()); } catch (ResourceNotFoundException $e) { $app->response()->status(400); $app->response()->header('X-Status-Reason', $e->getMessage()); } }); $app->post('/searchUser(/)', 'authenticate', function () use($app) { try { $us = new UsersService(); $request = $app->request(); $mediaType = $request->getMediaType(); $body = $request->getBody(); $input = json_decode($body); if ($input) { $su = Pdoconfig::ConvertoObj($input, 'searchUser'); } else { $su = new searchUser(); } $user = $us->searchUser($su); if ($user) { echo json_encode($user); } else { throw new ResourceNotFoundException(); } } catch (ResourceNotFoundException $e) { $app->response()->status(404); } catch (ResourceNotFoundException $e) { $app->response()->status(400); $app->response()->header('X-Status-Reason', $e->getMessage()); }
public function __destruct() { self::$dbh = null; R::close(); }