PHP code example of sy-records / oauth-login

1. Go to this page and download the library: Download sy-records/oauth-login 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/ */

    

sy-records / oauth-login example snippets


use Auth\QqConnect;

# https://connect.qq.com/manage.html#/ 创建应用
$appId = ''; # APP ID
$appKey = '';# APP Key
$callBackUrl = ''; # 授权回调地址

$qqAuth = new QqConnect($appId,$appKey,$callBackUrl);
# 授权登录页面
$qqAuth->qqLogin();
# 授权回调方法
$res = $qqAuth->qqCallBack();
var_dump($res); # 用户信息

use Auth\WeiboConnect;

# http://open.weibo.com/apps/new?sort=web 创建网站应用
$appKey = ''; # 网站应用申请后的App Key
$appSecret = ''; # 网站应用申请后的App Secret
$callback = ''; # 授权回调地址

$weiboAuth = new WeiboConnect($appKey,$appSecret,$callback);
# 授权登录页面
$weiboAuth->weiboLogin();
# 授权回调方法
$res = $weiboAuth->weiboCallBack();
var_dump($res); # 用户信息

use Auth\GithubConnect;

# https://github.com/settings/developers 创建OAuth App
$clientId = ''; # 创建OAuth App得到的Client ID
$clientSecret = ''; # 创建OAuth App得到的Client Secret
$callback = ''; # Authorization callback URL 回调地址

$githubAuth = new GithubConnect($clientId,$clientSecret,$callback);
# 授权登录页面
$githubAuth->githubLogin();
# 授权回调方法
$res = $githubAuth->githubCallBack();
var_dump($res); # 用户信息