{"id":13700093,"url":"https://github.com/Yurunsoft/YurunOAuthLogin","last_synced_at":"2025-05-04T18:34:16.365Z","repository":{"id":41156307,"uuid":"98140935","full_name":"Yurunsoft/YurunOAuthLogin","owner":"Yurunsoft","description":"PHP 第三方登录授权 SDK，集成了QQ、微信、微博、Github等常用接口。支持 php-fpm 和 Swoole，所有框架通用。QQ群：17916227","archived":false,"fork":false,"pushed_at":"2023-10-17T06:16:50.000Z","size":328,"stargazers_count":431,"open_issues_count":3,"forks_count":110,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-25T01:48:42.248Z","etag":null,"topics":["coroutine","oauth-client","oauth2","php","qqlogin","swoole","weixinlogin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yurunsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-07-24T02:24:12.000Z","updated_at":"2025-04-07T08:48:32.000Z","dependencies_parsed_at":"2023-10-12T18:00:39.640Z","dependency_job_id":"6b9dd8e8-7091-4199-abba-1b56c1209d12","html_url":"https://github.com/Yurunsoft/YurunOAuthLogin","commit_stats":{"total_commits":82,"total_committers":4,"mean_commits":20.5,"dds":0.1097560975609756,"last_synced_commit":"3f67cc3ead9e14963fd0a40efe066530fac60746"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2FYurunOAuthLogin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2FYurunOAuthLogin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2FYurunOAuthLogin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yurunsoft%2FYurunOAuthLogin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yurunsoft","download_url":"https://codeload.github.com/Yurunsoft/YurunOAuthLogin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252382919,"owners_count":21739240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coroutine","oauth-client","oauth2","php","qqlogin","swoole","weixinlogin"],"created_at":"2024-08-02T20:00:48.515Z","updated_at":"2025-05-04T18:34:11.357Z","avatar_url":"https://github.com/Yurunsoft.png","language":"PHP","funding_links":[],"categories":["Third-party SDK"],"sub_categories":[],"readme":"# YurunOAuthLogin\r\n\r\n[![Latest Version](https://img.shields.io/packagist/v/yurunsoft/yurun-oauth-login.svg)](https://packagist.org/packages/yurunsoft/yurun-oauth-login)\r\n[![IMI Doc](https://img.shields.io/badge/docs-passing-green.svg)](http://doc.yurunsoft.com/YurunOAuthLogin)\r\n[![IMI License](https://img.shields.io/github/license/Yurunsoft/YurunOAuthLogin.svg)](https://github.com/Yurunsoft/YurunOAuthLogin/blob/master/LICENSE)\r\n\r\n## 介绍\r\n\r\nYurunOAuthLogin 是一个 PHP 第三方登录授权 SDK，集成了 QQ、微信、微博、GitHub 等常用接口。\r\n\r\n无框架依赖，支持所有框架，支持 Swoole 协程环境。\r\n\r\n我们有完善的在线技术文档：[http://doc.yurunsoft.com/YurunOAuthLogin](http://doc.yurunsoft.com/YurunOAuthLogin)\r\n\r\nAPI 文档：[https://apidoc.gitee.com/yurunsoft/YurunOAuthLogin](https://apidoc.gitee.com/yurunsoft/YurunOAuthLogin)\r\n\r\n宇润PHP全家桶群：17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png \"点击加群\")](https://jq.qq.com/?_wv=1027\u0026k=5wXf4Zq)，如有问题会有人解答和修复。\r\n\r\n程序员日常划水群：74401592 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png \"点击加群\")](https://shang.qq.com/wpa/qunwpa?idkey=e2e6b49e9a648aae5285b3aba155d59107bb66fde02e229e078bd7359cac8ac3)。\r\n\r\n大家在开发中肯定会对接各种各样的第三方平台，我个人精力有限，欢迎各位来提交 PR （[GitHub](https://github.com/Yurunsoft/YurunOAuthLogin)），一起完善它，让它能够支持更多的平台，更加好用。\r\n\r\n## 支持的登录平台\r\n\r\n- QQ、QQ 小程序\r\n- 微信网页扫码、微信公众号、微信小程序\r\n- 支付宝网页、支付宝 APP、支付宝小程序\r\n- 微博\r\n- 百度\r\n- GitHub\r\n- Gitee\r\n- Coding\r\n- 开源中国(OSChina)\r\n- CSDN\r\n- GitLab\r\n- 飞书\r\n- 钉钉\r\n- 企业微信\r\n\r\n\u003e 后续将不断添加新的平台支持，也欢迎你来提交PR，一起完善！\r\n\r\n## 安装\r\n\r\n在您的 composer.json 中加入配置：\r\n\r\n`PHP \u003e= 5.5.0`\r\n\r\n```json\r\n{\r\n    \"require\": {\r\n        \"yurunsoft/yurun-oauth-login\": \"~3.0\"\r\n    }\r\n}\r\n```\r\n\r\n`PHP \u003c 5.5.0`\r\n\r\n```json\r\n{\r\n    \"require\": {\r\n        \"yurunsoft/yurun-oauth-login\": \"~2.0\"\r\n    }\r\n}\r\n```\r\n\r\n\u003e 3.x 版本支持 PHP \u003e= 5.5，持续迭代维护中\r\n\r\n\u003e 2.x 版本支持 PHP \u003e= 5.4，支持长期 BUG 维护，保证稳定可用，停止功能性更新\r\n\r\n## 代码实例\r\n\r\n自 v1.2 起所有方法统一参数调用，如果需要额外参数的可使用对象属性赋值，具体参考 test 目录下的测试代码。\r\n\r\n下面代码以 QQ 接口举例，完全可以把 QQ 字样改为其它任意接口字样使用。\r\n\r\n### 实例化\r\n\r\n```php\r\n$qqOAuth = new \\Yurun\\OAuthLogin\\QQ\\OAuth2('appid', 'appkey', 'callbackUrl');\r\n```\r\n\r\n### 登录\r\n\r\n```php\r\n$url = $qqOAuth-\u003egetAuthUrl();\r\n$_SESSION['YURUN_QQ_STATE'] = $qqOAuth-\u003estate;\r\nheader('location:' . $url);\r\n```\r\n\r\n### 回调处理\r\n\r\n```php\r\n// 获取accessToken\r\n$accessToken = $qqOAuth-\u003egetAccessToken($_SESSION['YURUN_QQ_STATE']);\r\n\r\n// 调用过getAccessToken方法后也可这么获取\r\n// $accessToken = $qqOAuth-\u003eaccessToken;\r\n// 这是getAccessToken的api请求返回结果\r\n// $result = $qqOAuth-\u003eresult;\r\n\r\n// 用户资料\r\n$userInfo = $qqOAuth-\u003egetUserInfo();\r\n\r\n// 这是getAccessToken的api请求返回结果\r\n// $result = $qqOAuth-\u003eresult;\r\n\r\n// 用户唯一标识\r\n$openid = $qqOAuth-\u003eopenid;\r\n```\r\n\r\n### 解决第三方登录只能设置一个回调域名的问题\r\n\r\n```php\r\n// 解决只能设置一个回调域名的问题，下面地址需要改成你项目中的地址，可以参考test/QQ/loginAgent.php写法\r\n$qqOAuth-\u003eloginAgentUrl = 'http://localhost/test/QQ/loginAgent.php';\r\n\r\n$url = $qqOAuth-\u003egetAuthUrl();\r\n$_SESSION['YURUN_QQ_STATE'] = $qqOAuth-\u003estate;\r\nheader('location:' . $url);\r\n```\r\n\r\n### Swoole 协程环境支持\r\n\r\n```php\r\n\\Yurun\\Util\\YurunHttp::setDefaultHandler('Yurun\\Util\\YurunHttp\\Handler\\Swoole');\r\n```\r\n\r\n## 特别鸣谢\r\n\r\n* [GetWeixinCode](https://github.com/HADB/GetWeixinCode \"GetWeixinCode\")\r\n\r\n## 捐赠\r\n\r\n\u003cimg src=\"https://raw.githubusercontent.com/Yurunsoft/YurunOAuthLogin/master/res/pay.png\"/\u003e\r\n\r\n开源不求盈利，多少都是心意，生活不易，随缘随缘……\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYurunsoft%2FYurunOAuthLogin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYurunsoft%2FYurunOAuthLogin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYurunsoft%2FYurunOAuthLogin/lists"}