PHPackages                             rjwu123/wechat-oauth - 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. rjwu123/wechat-oauth

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

rjwu123/wechat-oauth
====================

WeChat OAuth

1.0.0(7y ago)117MITPHPPHP &gt;= 5.4.0

Since Sep 20Pushed 7y agoCompare

[ Source](https://github.com/rjwu123/wechat-oauth)[ Packagist](https://packagist.org/packages/rjwu123/wechat-oauth)[ RSS](/packages/rjwu123-wechat-oauth/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Overview
--------

[](#overview)

微信OAuth登录

Installation
------------

[](#installation)

#### Composer (推荐)

[](#composer-推荐)

把下面的配置加入你的`composer.json`文件

```
"rjwu123/wechat-oauth": "dev-master"
```

然后使用[Composer](https://getcomposer.org/)来安装SDK

```
composer install
```

Usage
-----

[](#usage)

#### Autoload

[](#autoload)

如果你用Composer来安装，可以用以下代码自动加载

```
require 'vendor/autoload.php';
```

SDK位于全局命名空间下。

```
use rjwu123\wechat\Oauth
```

#### Initialization

[](#initialization)

实例化`OAuth`即可完成初始化

```
$oauth = new \rjwu123\wechat\OAuth($options);
```

`$appid`和`$secret`是微信开放平台的应用的唯一标识和秘钥AppSecret

#### Code samples

[](#code-samples)

```
require 'vendor/autoload.php';

use rjwu123\wechat\Oauth;

$oauth = new Oauth([
    'appid' => 'xxxx',
    'appsecret' => 'xxxx',
    'redirectUri' => 'http://www.test.com',
    'scope' => 'snsapi_userinfo'
        ]);

// 第一步：用户同意授权，获取code
$authUrl = $oauth->getAuthorizationUrl();
if (!isset($_GET['code'])) {
    $oauth->redirect($authUrl);
} else {
    // 第二步：通过code换取网页授权access_token
    $res = $oauth->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);
    if (isset($res['errcode']) && $res['errcode'] > 0) {
        $oauth->redirect($authUrl);
        return;
    } else {
        // 第四步：拉取用户信息(需scope为 snsapi_userinfo)
        if ($res['scope'] == 'snsapi_userinfo') {
            $info = $oauth->getUserInfo($res);
        }
    }

    // 第三步：刷新access_token
    $url = $oauth->getAccessToken('refresh_token', [
        'refresh_token' => $res['refresh_token']
    ]);
}
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

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

2840d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43427722?v=4)[rj\_wu](/maintainers/rjwu123)[@rjwu123](https://github.com/rjwu123)

---

Top Contributors

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

---

Tags

oauthloginwechatweixinweixinoauthwechatoauthweixinloginwechatloginwechat-oauthweixin-oauth

### Embed Badge

![Health badge](/badges/rjwu123-wechat-oauth/health.svg)

```
[![Health](https://phpackages.com/badges/rjwu123-wechat-oauth/health.svg)](https://phpackages.com/packages/rjwu123-wechat-oauth)
```

###  Alternatives

[henter/wechat-oauth

WeChat OAuth SDK

3444.5k2](/packages/henter-wechat-oauth)[overtrue/socialite

A collection of OAuth 2 packages.

1.4k5.6M90](/packages/overtrue-socialite)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40921.3M85](/packages/auth0-auth0-php)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.2M3](/packages/auth0-login)[oakhope/oauth2-wechat

微信登录认证授权 Wechat login authorization. This package provides Wechat OAuth 2.0 support for the PHP League's OAuth 2.0 Client

229.0k](/packages/oakhope-oauth2-wechat)

PHPackages © 2026

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