PHP code example of leo0o / sns-oauth

1. Go to this page and download the library: Download leo0o/sns-oauth library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

leo0o / sns-oauth example snippets


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'       =>  ''
]