jzyuchen/oauth-client

oauth client for laravel
57 9
Install
composer require jzyuchen/oauth-client
PHP:>=5.3.3
License:MIT
Last Updated:Jun 9, 2015
Links: GitHub  ·  Packagist
Maintainer: jzyuchen

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>';

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

404,034,618 608
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

384,821,166 4,658