{"id":23378068,"url":"https://github.com/powerdos/wechatoauth2.0","last_synced_at":"2026-03-17T04:44:37.212Z","repository":{"id":126316113,"uuid":"84648379","full_name":"PowerDos/WeChatOAuth2.0","owner":"PowerDos","description":"基于ThinkPHP3.2.3的微信OAuth2.0网页授权认证模块","archived":false,"fork":false,"pushed_at":"2017-03-12T02:45:46.000Z","size":946,"stargazers_count":11,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T20:17:24.545Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PowerDos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-11T12:27:44.000Z","updated_at":"2024-03-13T12:46:19.000Z","dependencies_parsed_at":"2023-06-16T06:45:35.818Z","dependency_job_id":null,"html_url":"https://github.com/PowerDos/WeChatOAuth2.0","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PowerDos/WeChatOAuth2.0","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerDos%2FWeChatOAuth2.0","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerDos%2FWeChatOAuth2.0/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerDos%2FWeChatOAuth2.0/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerDos%2FWeChatOAuth2.0/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PowerDos","download_url":"https://codeload.github.com/PowerDos/WeChatOAuth2.0/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerDos%2FWeChatOAuth2.0/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013625,"owners_count":26085298,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-12-21T18:34:29.103Z","updated_at":"2025-10-13T00:21:28.627Z","avatar_url":"https://github.com/PowerDos.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WeChatOAuth2.0\n基于ThinkPHP3.2.3的微信OAuth2.0网页授权认证模块\u003cbr\u003e\n## Step 1\n将全部文件放在网站目录下\u003cbr\u003e\n## Step 2\n配置你的公众号信息\u003cbr\u003e\n* 进入文件./Application/Common/Conf/config.php\u003cbr\u003e\n* 将你的公众号相关信息写入\u003cbr\u003e\n```PHP\n\u003c?php\n//这里填入的你域名\ndefine(\"_URL_\",\"www.baidu.com\");\n//这里填入你公众号的APPID\ndefine(\"_APPID_\",\"你公众号的APPID\");\n//这里填入你公众号的APPSECRET\ndefine('_APPSECRET_','你公众号的APPSECRET');\nreturn array(\n\t//'配置项'=\u003e'配置值'\n\t'DB_TYPE'               =\u003e  'mysql',     // 数据库类型\n    'DB_HOST'               =\u003e  '127.0.0.1', // 服务器地址\n    'DB_NAME'               =\u003e  '',          // 数据库名\n    'DB_USER'               =\u003e  '',      // 用户名\n    'DB_PWD'                =\u003e  '',          // 密码\n    'DB_PORT'               =\u003e  '3306',        // 端口\n\t'DB_PARAMS' =\u003e array(\\PDO::ATTR_CASE =\u003e \\PDO::CASE_NATURAL) ,\n\t'MODULE_ALLOW_LIST'    =\u003e    array('Home','Admin'),//模块\n\t'DEFAULT_MODULE'       =\u003e    'Home',\n\t'URL_ROUTER_ON'   =\u003e true, \n\t'URL_ROUTE_RULES'=\u003earray(\n\t    'index$' =\u003e 'Home/Index/index', //定义路由\n\t)\n);\n```\n## Step 3\n新建的控制器继承OAuth2Controller类即可实现微信网页授权认证功能\u003cbr\u003e\nOAuth2Controller类的相关代码\u003cbr\u003e\n```PHP\n\u003c?php\nnamespace Home\\Controller;\nuse Think\\Controller;\nclass OAuth2Controller extends Controller {\n    public function _initialize(){\n    \t//判断是否验证过\n\t\tif((session(\"?userOpenid\")\u0026\u0026session(\"?userSex\"))||(session(\"?userOpenid\")\u0026\u0026session(\"?userNickname\"))){\n\t\t\t//已验证过\n\t\t\t//如果你不需要用户绑定的话，可以跳过下面这步\n\t\t\tif(!session(\"?userID\")){\n\t\t\t\t$this-\u003eredirect('这里填入要跳转的绑定页面','',2,\"\u003ch1\u003e请先绑定账号再使用,将自动跳转到绑定页面\u003c/h1\u003e\");\n\t\t\t}\n\t\t}else{\n\t\t//进入验证\n\t\t//方法放在./Application/Home/Common/function.php下\n\t\t\tCheck();\n\t\t}\n\t}\n}\n```\n## Demo\n```PHP\n\u003c?php \nnamespace Home\\Controller;\nclass DemoController extends OAuth2Controller {\n    public function index(){\n        $this-\u003eshow(\"这个是测试案例\");\n    }\n}\n```\n## P.S.\n相关认证代码放在目录`./Application/Home/Common/function.php`下(不是用TP写的小伙伴可以在这里参考下认证代码)\u003cbr\u003e\n注意要创建相应的数据库和表。具体更改在function目录下更改`getUserInfo()`方法就好\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowerdos%2Fwechatoauth2.0","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowerdos%2Fwechatoauth2.0","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowerdos%2Fwechatoauth2.0/lists"}