leo0o/sns-oauth

another php lib for sns oauth2.0

1.0.8 2020-12-02 02:50 UTC

This package is auto-updated.

Last update: 2024-06-29 04:33:18 UTC


README

sns-oauth

oauth2.0 通过回调返回的code获取用户相关信息,支持平台:

  • 微博
  • 微信
  • qq

安装

php composer.phar require leo0o/sns-oauth or composer require leo0o/sns-oauth

使用

try {
    $wechat = new \oauth\OAuth('平台类型, 如:\SNSOAuth\Common\Platform::SINA_WEIBO' , [
            'appKey'=>'你的appkey',
            'appSecret'=>'你的appsecret',
            'redirectUrl'=>'回调地址,必传'
            ]);
    $userinfo = $wechat->Authrize('回调带回的code');
} catch (OAuthException $e) {
    var_dump(echo $e->getMessage());
}

返回格式:

[
    'nickname'      =>  '',   
    'openid'        =>  '',   
    'sex'           =>  '',   //0未知, 1男, 2女
    'headimgurl'    =>  '',
    'unionid'       =>  ''
]