$this->rest->response('', 406); } $me = array('displayName' => 'Usuario demo', 'email' => '*****@*****.**', 'sdfName' => 'Usuario demo'); if (!empty($me)) { $this->rest->response($this->json($me), 200); } $this->rest->response($this->json(array('resultado' => $cantidad)), 204); } private function login() { if ($this->rest->get_request_method() == "POST") { $dato = json_decode(file_get_contents('php://input')); //get user from $usuario = isset($dato->email) ? $dato->email : ''; $clave = isset($dato->password) ? $dato->password : ''; $usuariodb = array('id' => 1, 'email' => 'admin', 'password' => '1234', 'rol' => 'lector'); if ($usuario == $usuariodb['email'] && $clave == $usuariodb['password']) { //$uid = $this->sesion->sesion_init(); $token = $this->getToken(array('usuario' => 'admin', 'clave' => '1234', 'rol' => 'lector')); $this->rest->_token = $token; $this->rest->response($this->json(array('tokenja' => $token, 'msg' => 'autorizado', 'uid' => $dato)), 200); } $this->rest->response($this->json(array('tokenja' => 'invalido', 'message' => 'Usuario o clave incorrecto')), 401); } else { $this->rest->response('', 404); } } } $api = new api(); $api->processApi();