PHPackages                             yurunsoft/yurun-oauth-login - 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. yurunsoft/yurun-oauth-login

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

yurunsoft/yurun-oauth-login
===========================

YurunOAuthLogin 是一个 PHP 第三方登录授权 SDK，集成了 QQ、微信、微博、GitHub 等常用接口。

v3.1.1(1mo ago)46070.2k↑390.3%111[1 issues](https://github.com/Yurunsoft/YurunOAuthLogin/issues)[1 PRs](https://github.com/Yurunsoft/YurunOAuthLogin/pulls)MITPHPPHP &gt;=5.5

Since Jul 24Pushed 2y ago18 watchersCompare

[ Source](https://github.com/Yurunsoft/YurunOAuthLogin)[ Packagist](https://packagist.org/packages/yurunsoft/yurun-oauth-login)[ RSS](/packages/yurunsoft-yurun-oauth-login/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (4)Versions (30)Used By (0)

YurunOAuthLogin
===============

[](#yurunoauthlogin)

[![Latest Version](https://camo.githubusercontent.com/24d357e4952e692448510b10d960f8293573f2440b79157c9b88c6a1024f5e45/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f797572756e736f66742f797572756e2d6f617574682d6c6f67696e2e737667)](https://packagist.org/packages/yurunsoft/yurun-oauth-login)[![IMI Doc](https://camo.githubusercontent.com/8a45ed26be92338e9c97fc73a6d772a77ee94fb973e93efc89decb1ea59a8bd7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d70617373696e672d677265656e2e737667)](http://doc.yurunsoft.com/YurunOAuthLogin)[![IMI License](https://camo.githubusercontent.com/6aa92186edaae8cbdfc2592a80b46e5a060d7e2e6b66899aa003297d6b4cfbd3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f597572756e736f66742f597572756e4f417574684c6f67696e2e737667)](https://github.com/Yurunsoft/YurunOAuthLogin/blob/master/LICENSE)

介绍
--

[](#介绍)

YurunOAuthLogin 是一个 PHP 第三方登录授权 SDK，集成了 QQ、微信、微博、GitHub 等常用接口。

无框架依赖，支持所有框架，支持 Swoole 协程环境。

我们有完善的在线技术文档：

API 文档：

宇润PHP全家桶群：17916227 [![点击加群](https://camo.githubusercontent.com/75b53e353bb9e5064662e185a6d39f4bb88c4e45bd3a1240ddf599525edb6afa/68747470733a2f2f7075622e69647171696d672e636f6d2f7770612f696d616765732f67726f75702e706e67 "点击加群")](https://jq.qq.com/?_wv=1027&k=5wXf4Zq)，如有问题会有人解答和修复。

程序员日常划水群：74401592 [![点击加群](https://camo.githubusercontent.com/75b53e353bb9e5064662e185a6d39f4bb88c4e45bd3a1240ddf599525edb6afa/68747470733a2f2f7075622e69647171696d672e636f6d2f7770612f696d616765732f67726f75702e706e67 "点击加群")](https://shang.qq.com/wpa/qunwpa?idkey=e2e6b49e9a648aae5285b3aba155d59107bb66fde02e229e078bd7359cac8ac3)。

大家在开发中肯定会对接各种各样的第三方平台，我个人精力有限，欢迎各位来提交 PR （[GitHub](https://github.com/Yurunsoft/YurunOAuthLogin)），一起完善它，让它能够支持更多的平台，更加好用。

支持的登录平台
-------

[](#支持的登录平台)

- QQ、QQ 小程序
- 微信网页扫码、微信公众号、微信小程序
- 支付宝网页、支付宝 APP、支付宝小程序
- 微博
- 百度
- GitHub
- Gitee
- Coding
- 开源中国(OSChina)
- CSDN
- GitLab
- 飞书
- 钉钉
- 企业微信

> 后续将不断添加新的平台支持，也欢迎你来提交PR，一起完善！

安装
--

[](#安装)

在您的 composer.json 中加入配置：

`PHP >= 5.5.0`

```
{
    "require": {
        "yurunsoft/yurun-oauth-login": "~3.0"
    }
}
```

`PHP < 5.5.0`

```
{
    "require": {
        "yurunsoft/yurun-oauth-login": "~2.0"
    }
}
```

> 3.x 版本支持 PHP &gt;= 5.5，持续迭代维护中

> 2.x 版本支持 PHP &gt;= 5.4，支持长期 BUG 维护，保证稳定可用，停止功能性更新

代码实例
----

[](#代码实例)

自 v1.2 起所有方法统一参数调用，如果需要额外参数的可使用对象属性赋值，具体参考 test 目录下的测试代码。

下面代码以 QQ 接口举例，完全可以把 QQ 字样改为其它任意接口字样使用。

### 实例化

[](#实例化)

```
$qqOAuth = new \Yurun\OAuthLogin\QQ\OAuth2('appid', 'appkey', 'callbackUrl');
```

### 登录

[](#登录)

```
$url = $qqOAuth->getAuthUrl();
$_SESSION['YURUN_QQ_STATE'] = $qqOAuth->state;
header('location:' . $url);
```

### 回调处理

[](#回调处理)

```
// 获取accessToken
$accessToken = $qqOAuth->getAccessToken($_SESSION['YURUN_QQ_STATE']);

// 调用过getAccessToken方法后也可这么获取
// $accessToken = $qqOAuth->accessToken;
// 这是getAccessToken的api请求返回结果
// $result = $qqOAuth->result;

// 用户资料
$userInfo = $qqOAuth->getUserInfo();

// 这是getAccessToken的api请求返回结果
// $result = $qqOAuth->result;

// 用户唯一标识
$openid = $qqOAuth->openid;
```

### 解决第三方登录只能设置一个回调域名的问题

[](#解决第三方登录只能设置一个回调域名的问题)

```
// 解决只能设置一个回调域名的问题，下面地址需要改成你项目中的地址，可以参考test/QQ/loginAgent.php写法
$qqOAuth->loginAgentUrl = 'http://localhost/test/QQ/loginAgent.php';

$url = $qqOAuth->getAuthUrl();
$_SESSION['YURUN_QQ_STATE'] = $qqOAuth->state;
header('location:' . $url);
```

### Swoole 协程环境支持

[](#swoole-协程环境支持)

```
\Yurun\Util\YurunHttp::setDefaultHandler('Yurun\Util\YurunHttp\Handler\Swoole');
```

特别鸣谢
----

[](#特别鸣谢)

- [GetWeixinCode](https://github.com/HADB/GetWeixinCode "GetWeixinCode")

捐赠
--

[](#捐赠)

[![](https://raw.githubusercontent.com/Yurunsoft/YurunOAuthLogin/master/res/pay.png)](https://raw.githubusercontent.com/Yurunsoft/YurunOAuthLogin/master/res/pay.png)

开源不求盈利，多少都是心意，生活不易，随缘随缘……

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance52

Moderate activity, may be stable

Popularity52

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 84.6% 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

Every ~116 days

Recently: every ~421 days

Total

29

Last Release

34d ago

Major Versions

v1.2.7 → v2.0.02018-07-09

v2.x-dev → v3.0.02020-03-24

PHP version history (3 changes)v1.2.4PHP &gt;=5.4

v3.0.0PHP &gt;=7.1

v3.0.2PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f917bb42280d114c53cebadc2942a13ee03abe14971089f88895e266d637169?d=identicon)[Yurunsoft](/maintainers/Yurunsoft)

---

Top Contributors

[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (77 commits)")[![sy-records](https://avatars.githubusercontent.com/u/33931153?v=4)](https://github.com/sy-records "sy-records (12 commits)")[![gchehe](https://avatars.githubusercontent.com/u/26815935?v=4)](https://github.com/gchehe "gchehe (1 commits)")[![wei98k](https://avatars.githubusercontent.com/u/29112597?v=4)](https://github.com/wei98k "wei98k (1 commits)")

---

Tags

coroutineoauth-clientoauth2phpqqloginswooleweixinlogin

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/yurunsoft-yurun-oauth-login/health.svg)

```
[![Health](https://phpackages.com/badges/yurunsoft-yurun-oauth-login/health.svg)](https://phpackages.com/packages/yurunsoft-yurun-oauth-login)
```

###  Alternatives

[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)[kissdigital-com/apple-sign-in-client-secret-generator

PHP package for generating 'client secret' for Sign In with Apple

2125.5k](/packages/kissdigital-com-apple-sign-in-client-secret-generator)[firemultimedia/mautic-multi-captcha-bundle

This plugin brings Google's reCAPTCHA, hCaptcha, and Cloudflare Turnstile integration to mautic.

151.4k](/packages/firemultimedia-mautic-multi-captcha-bundle)

PHPackages © 2026

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