2017 © Pedro Peláez
 

library oauth2-sinaweibo

Sina Weibo OAuth 2.0 Client Provider for The PHP League OAuth2-Client

image

xiabin/oauth2-sinaweibo

Sina Weibo OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

SinaWeibo Provider for OAuth 2.0 Client

license Packagist Build Status Coverage Status Quality Score Packagist, (*1)

这个组件基于 PHP League's OAuth 2.0 Client., (*2)

安装

用composer安装:, (*3)

composer require xiabin/oauth2-sinaweibo

用例

获取token

$provider = new Xiabin\OAuth2\Client\Provider\SinaWeibo([
    'clientId'          => '{sinaweibo-client-id}',
    'clientSecret'      => '{sinaweibo-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
]);

if (!isset($_GET['code'])) {

    //如果没有code就去获取
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

  //判断state与之前使用的是否一致
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    //获取accesstoken
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    ...
}

测试

bash $ ./vendor/bin/phpunit, (*4)

License

The MIT License (MIT). Please see License File for more information., (*5)

The Versions

04/07 2016

dev-master

9999999-dev

Sina Weibo OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authorization oauth client oauth2 authorisation sina weibo

04/07 2016

v1.0.1

1.0.1.0

Sina Weibo OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authorization oauth client oauth2 authorisation sina weibo

25/06 2016

v1.0.0

1.0.0.0

Sina Weibo OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authorization oauth client oauth2 authorisation sina weibo

25/06 2016

v0.1.0

0.1.0.0

Sina Weibo OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authorization oauth client oauth2 authorisation sina weibo