PHPackages                             mingge2016/oauthsdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. mingge2016/oauthsdk

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

mingge2016/oauthsdk
===================

第三方登录

1.0.0(8y ago)048MITPHPPHP &gt;=5.3.0

Since Dec 12Pushed 8y agoCompare

[ Source](https://github.com/mingge2016/oauthsdk)[ Packagist](https://packagist.org/packages/mingge2016/oauthsdk)[ RSS](/packages/mingge2016-oauthsdk/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)DependenciesVersions (2)Used By (0)

OauthSDK
========

[](#oauthsdk)

QQ、微信、微博、第三方登录SDK

安装
--

[](#安装)

使用 Composer 安装:

```
composer require "mingge2016/oauthsdk":"dev-master"

```

### 如何使用

[](#如何使用)

```
html
    QQ登录
    微信登录
    新浪登录
```

```
use OauthSDK\Oauth;

$config =  array(
    //腾讯QQ登录配置
    'QQ' => array(
        'APP_KEY' => '123456', //应用注册成功后分配的 APP ID
        'APP_SECRET' => '9cc9ac2fb17d010104d8a58dbebb4d3a', //应用注册成功后分配的KEY
        'CALLBACK' =>  'http://www.example.com/callback.php?type=qq',//回调URL
    ),
    //新浪微博配置
    'SINA' => array(
        'APP_KEY' => '123456', //应用注册成功后分配的 APP ID
        'APP_SECRET' => '9cc9ac2fb17d010104d8a58dbebb4d3a', //应用注册成功后分配的KEY
        'CALLBACK' => 'http://www.example.com/callback.php?type=sina',//回调URL
    ),
    //腾讯微信配置
    'WECHAT' => array(
        'APP_KEY' => '123456', //应用注册成功后分配的 APP ID
        'APP_SECRET' => '9cc9ac2fb17d010104d8a58dbebb4d3a', //应用注册成功后分配的KEY
        'CALLBACK' => 'http://www.example.com/callback.php?type=wechat',//回调URL
    )
);
//login
$type = $_GET['type'];
$sns = Oauth::getInstance($type,$config);
//跳转到授权页面
header('Location: ' . $sns->getRequestCodeURL());

//callback
$type = $_GET['type'];
$code = $_GET['code'];

(empty($type) || empty($code)) && exit('参数错误');
$sns = Oauth::getInstance($type,$config);
$tokenArr = $sns->getAccessToken($code);

$openid = $tokenArr['openid'];
$token = $tokenArr['access_token'];
//获取当前登录用户信息
if ($openid) {
    $userinfo = $userInfo = $sns->getUserInfo();
    exit( 'SUCCESS');
} else {
    exit('系统出错;请稍后再试！');
}
```

License
=======

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3076d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e39b62e33dfaab45baf224f29006b1c995424a3e81d90b0bcb0a43ec323f83fe?d=identicon)[gzm](/maintainers/gzm)

---

Top Contributors

[![mingge2016](https://avatars.githubusercontent.com/u/24652531?v=4)](https://github.com/mingge2016 "mingge2016 (4 commits)")

### Embed Badge

![Health badge](/badges/mingge2016-oauthsdk/health.svg)

```
[![Health](https://phpackages.com/badges/mingge2016-oauthsdk/health.svg)](https://phpackages.com/packages/mingge2016-oauthsdk)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
