PHPackages                             orq/wxpn - 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. [API Development](/categories/api)
4. /
5. orq/wxpn

ActiveLibrary[API Development](/categories/api)

orq/wxpn
========

The PHP library to make WeiXin Public Number Development easier

11PHP

Since May 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/rockysynergy/wxpn)[ Packagist](https://packagist.org/packages/orq/wxpn)[ RSS](/packages/orq-wxpn/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (2)Used By (0)

wxpn
====

[](#wxpn)

微信公众号开发PHP库
===========

[](#微信公众号开发php库)

wxpn
====

[](#wxpn-1)

微信公众号开发PHP库

安装
==

[](#安装)

1. `composer require orq/wxpn`
2. 下载本仓库的代码，使用示例如下：

```
    include_once ROOT.'/wxpn/wxpn_autoloader.php';
    $wQrCode = new Orq\Wxpn\QrCode(WX_APPID, WX_APPSECRET);
```

手册
==

[](#手册)

Oauth2 （网页授权）
-------------

[](#oauth2-网页授权)

1. 根据[文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140842)完成配置
2. 代码调用示例：

```
// 第一步
$wAuth = new Orq\Wxpn\Auth($appid, $secret);
$redirect_url = 'http://my.com/path_for_wxlogin';
$jumpurl = $wAuth->oauth2AuthorizeUrl($redirect_url, "snsapi_userinfo", "123");
header("Location: $jumpurl");

// 第二步 (http://my.com/path_for_wxlogin所在的页面)
$code = $_GET['code'];
$access_token_oauth2 = $wAuth->oauth2AccessToken($code); // 如果scope是snsapi_base则流程到此结束

// 第三步
$userinfo = $this->wAuth-> oauth2GetUserInfo($access_token_oauth2['access_token']
```

自定义菜单
-----

[](#自定义菜单)

1. [开发文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013)
2. 代码示例

```
$wMenu = new Orq\Wxpn\Menu($appid, $secret);
$button = [
    [
        'name' => '享睡雅兰',
        'sub_button' => [
            [
                'type' => "view",
                'name' => "关于我们",
                'url'  => "http://www.my_domain.com/about_us"
            ],
            [
                'type' => 'click',
                'name' => '客服电话',
                'key' => '40088223344'
            ]
        ]
    ]
];
$wMenu->create($button);
```

3. 假设上面的代码在[https://mydoman.com/create\_menu，访问此url](https://mydoman.com/create_menu%EF%BC%8C%E8%AE%BF%E9%97%AE%E6%AD%A4url)

生成渠道二维码海报
---------

[](#生成渠道二维码海报)

1. [文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1443433542)
2. 示例代码

```
$wQrCode = new Orq\Wxpn\QrCode($appid, $secret);
$sceneId = 33;
$qrPath = './path_to_store/'.$sceneId.'.jpg'
$wQrCode->getQrCode($type, $sceneId, $qrPath);

$wQrCode->makePoster($qrPath, $bgFilePath, $targetPath);
```

3. 海报文件存储在$targetPath
4. 用户扫描海报时会发送`订阅`事件，[文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140454)
5. 代码调用示例

```
// 首先需要实现接口
class RegisterService implements Orq\Wxpn\QrcodeJoinSubstriberInterface
{
    /**
     * $userInfo 为新用户的信息
     * $sceneId 为场景（渠道）值
     */
    public function notify(array $userInfo, string $sceneId):void
    {
    }
}

$registerService = new RegisterService();
$wMessage = new Orq\Wxpn\Message($appid, $secret);
$wMessage->subscribeQrcodeJoin（$regiseterService);
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1762050?v=4)[Rocky Ou](/maintainers/rockysynergy)[@rockysynergy](https://github.com/rockysynergy)

---

Top Contributors

[![rockysynergy](https://avatars.githubusercontent.com/u/1762050?v=4)](https://github.com/rockysynergy "rockysynergy (8 commits)")[![rocky56798](https://avatars.githubusercontent.com/u/54313332?v=4)](https://github.com/rocky56798 "rocky56798 (2 commits)")

### Embed Badge

![Health badge](/badges/orq-wxpn/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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