PHPackages                             yuunie/wechatauth - 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. yuunie/wechatauth

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

yuunie/wechatauth
=================

v1.0(7y ago)0101PHP

Since Apr 26Pushed 7y agoCompare

[ Source](https://github.com/yuunie/WeChatAuth)[ Packagist](https://packagist.org/packages/yuunie/wechatauth)[ RSS](/packages/yuunie-wechatauth/feed)WikiDiscussions master Synced 1mo ago

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

WeChatAuth
==========

[](#wechatauth)

- 获取微信 OpenID &amp; access\_token &amp; refresh\_token

0\_0
----

[](#0_0)

### 简单信息

[](#简单信息)

`namespace Yuunie;`

`class WeChatAuth`

`static function getCode($appid, $redirectUrl) :string`(URL需要在微信中打开)

微信打开URL redirectUrl页面获取code 调用getData

`static function getData($appid, $secret, $code) :array`

```
"access_token"
"expires_in"
"refresh_token"
"openid"
"scope"

```

### 获取流程

[](#获取流程)

```
通过getCodeUrl并传入微信APPID和回调链接（回调链接需要在微信公众平台-接口权限-网页授权获取用户基本信息-修改-网页授权域名中添加）获取URL
通过微信访问获取的URL，获取成功后将会回调设置的回调链接并带上?code=xxxxxxx
通过回调链接的页面获得code
使用getData并传入APPID、APPSecret和获取到的code获取该APPID所对应的access_token,refresh_token,openid
数据只能获取一次
如需重新获取需要重新开始

```

### 例子

[](#例子)

```
$appid = 'xxxxxxxx';
$secret = 'xxxxxxxxxxxxxxxx';

```

`Yuunie\WeChatAuth::getCodeUrl($appid, 'https://test.com/callback');`

- `https://test.com/callback` 所对应内容：

```
$code = $_GET['code'] ?? '';
$data = Yuunie\WeChatAuth::getData($appid, $secret, $code);
echo $data['openid'] ?? '获取OpenID失败';

```

END

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

2570d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/yuunie-wechatauth/health.svg)

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

###  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.2M117](/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)
