本文整理匯總了PHP中Sentinel::api_session方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sentinel::api_session方法的具體用法?PHP Sentinel::api_session怎麽用?PHP Sentinel::api_session使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sentinel
的用法示例。
在下文中一共展示了Sentinel::api_session方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: signInWithAccessToken
/**
* Sign in user with its access token
* The signin is only available for this call, no session
*
* @param string $accesstoken
*
* @return array the user informations or false if failed
*/
public static function signInWithAccessToken($accesstoken)
{
$username = self::getUsernameFromAccessToken($accesstoken);
if (is_null($username)) {
return false;
}
$ip = self::getClientIp();
$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$ts = date("U");
$cu = get_current_url(true);
self::$api_session = array('username' => $username);
self::$auth['users'][$username]['api_logincount'] = (int) @self::$auth['users'][$username]['api_logincount'] + 1;
self::$auth['users'][$username]['api_lastlogin'] = array('ip' => $ip, 'ua' => $ua, 'ts' => $ts);
if (!is_null($cu)) {
self::$auth['users'][$username]['api_lastlogin']['ur'] = $cu;
}
self::save();
return self::$auth['users'][$username];
}