jzyuchen / laravel-5-oauth-client by jzyuchen

oauth client for laravel
57
9
2
Package Data
Maintainer Username: jzyuchen
Maintainer Contact: jzyuchen@163.com (Jzyuchen)
Package Create Date: 2015-05-12
Package Last Update: 2015-06-09
Language: PHP
License: MIT
Last Refreshed: 2024-11-14 15:15:25
Package Statistics
Total Downloads: 57
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 9
Total Watchers: 2
Total Forks: 6
Total Open Issues: 0

laravel-5-oauth-client

qq, weibo, weixin oauth for laravel 5

QQ 调用示例

1.获取QQ验证的用户确认URL

$oauth = new OAuthClient();
$qq = $oauth->get('qq');
echo $qq->getAuthorizationUrl();

2.QQ回调处理

$oauth = new OAuthClient();
$provider = $oauth->get('qq');
// Try to get an access token (using the authorization code grant)
$token = $provider->getAccessToken('authorization_code', [
    'code' => Input::get('code')
]);

// Optional: Now you have a token you can look up a users profile data
try {

    // We got an access token, let's now get the user's details
    $userDetails = $provider->getUserDetails($token);
    // Use these details to create a new profile
    printf('Hello %s!', $userDetails->firstName);

} catch (Exception $e) {

    // Failed to get user details
    exit('Oh dear...');
}

echo '<pre>';
var_dump($userDetails);
echo "\n";

// Use this to interact with an API on the users behalf
echo $token->accessToken."\n";

// Use this to get a new access token if the old one expires
echo $token->refreshToken."\n";

// Number of seconds until the access token will expire, and need refreshing
echo $token->expires."\n";

var_dump($token);
echo '</pre>';