where("access_key", "=", $access_token) ->find(); if (!$key->loaded()) { throw new Rest_Exception("Forbidden", 403); } $user = identity::lookup_user($key->user_id); if (empty($user)) { throw new Rest_Exception("Forbidden", 403); } identity::set_active_user($user); } static function send_headers($exception) { header("HTTP/1.1 " . $exception->getCode() . " " . $exception->getMessage()); } }