本文整理汇总了PHP中rest::get_access_token方法的典型用法代码示例。如果您正苦于以下问题:PHP rest::get_access_token方法的具体用法?PHP rest::get_access_token怎么用?PHP rest::get_access_token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rest
的用法示例。
在下文中一共展示了rest::get_access_token方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_with_access_key_test
public function get_with_access_key_test()
{
$key = rest::get_access_token(1);
// admin user
$_SERVER["REQUEST_METHOD"] = "GET";
$_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $key->access_key;
$_GET["key"] = "value";
$this->assert_array_equal_to_json(array("params" => array("key" => "value"), "method" => "get", "access_token" => $key->access_key, "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock")));
}
示例2: index
public function index()
{
$username = Input::instance()->post("user");
$password = Input::instance()->post("password");
$user = identity::lookup_user_by_name($username);
if (empty($user) || !identity::is_correct_password($user, $password)) {
throw new Rest_Exception("Forbidden", 403);
}
$key = rest::get_access_token($user->id);
rest::reply($key->access_key);
}
示例3: index
public function index()
{
$username = Input::instance()->post("user");
$password = Input::instance()->post("password");
if (empty($username) || auth::too_many_failures($username)) {
throw new Rest_Exception("Forbidden", 403);
}
$user = identity::lookup_user_by_name($username);
if (empty($user) || !identity::is_correct_password($user, $password)) {
module::event("user_login_failed", $username);
throw new Rest_Exception("Forbidden", 403);
}
auth::login($user);
$key = rest::get_access_token($user->id);
rest::reply($key->access_key);
}