abei2017/yii2-wx

一个专注于yii2的微信sdk

Installs: 2 772

Dependents: 0

Suggesters: 0

Security: 0

Stars: 151

Watchers: 11

Forks: 54

Open Issues: 5

Type:yii2-extension

1.3.6 2020-12-02 01:25 UTC

This package is auto-updated.

Last update: 2024-03-27 09:37:42 UTC


README

yii2-wx Logo

一款服务于yii2的微信SDK(公众号、小程序、开放平台和企业微信)

68747470733a2f2f706f7365722e707567782e6f72672f61626569323031372f796969322d77782f762f737461626c65 68747470733a2f2f706f7365722e707567782e6f72672f61626569323031372f796969322d77782f646f776e6c6f616473 68747470733a2f2f706f7365722e707567782e6f72672f61626569323031372f796969322d77782f762f756e737461626c65 68747470733a2f2f706f7365722e707567782e6f72672f61626569323031372f796969322d77782f6c6963656e7365

文档

业务的实现方案以及生态

系统需求(Requirement)

  • PHP >= 5.4
  • Composer
  • openssl
  • fileinfo

安装(Installation)

$ composer require "abei2017/yii2-wx" -vvv

配置(set)

配置参数建议存放到yii2的配置文件中,例如基础版yii2可以如下配置

return [
    'wx'=>[
        //  公众号信息
        'mp'=>[
            //  账号基本信息
            'app_id'  => '', // 公众号的appid
            'secret'  => '', // 公众号的秘钥
            'token'   => '', // 接口的token
            'encodingAESKey'=>'',
            'safeMode'=>0,

            //  微信支付
            'payment'=>[
                'mch_id'        =>  '',// 商户ID
                'key'           =>  '',// 商户KEY
                'notify_url'    =>  '',// 支付通知地址
                'cert_path'     => '',// 证书
                'key_path'      => '',// 证书
            ],

            // web授权
            'oauth' => [
                'scopes'   => 'snsapi_userinfo',// 授权范围
                'callback' => '',// 授权回调
            ],
        ],

        //  小程序配置
        'mini'=>[
            //  基本配置
            'app_id'  => '', 
            'secret'  => '',
            'token' => '',
            'safeMode'=>0,
            'encodingAESKey'=>'',
            //  微信支付
            'payment' => [
                'mch_id'        => '',
                'key'           => '',
            ],
        ]
    ]
];

对于配置,请不要修改数据的key值。

使用(use)

yii2-wx采用单一接口驱动功能的思路,比如下面的代码将生成一个微信带参数的二维码。

use abei2017\wx\Application;

//  方法一
$qrcode = (new Application())->driver('mp.qrcode');

//  方法二
$conf = Yii::$app->params['wechat'];// 自定义配置数组key(最后一层数组key不可以更改)
$app = new Application(['conf'=>$conf]);

$qrcode = $app->driver('mp.qrcode');
$data = $qrcode->intTemp(3600,9527);// 生成一个数字类临时二维码,有效期为3600秒

功能实现

微信公众号

  • 获取接口调用凭证
  • 获取微信服务器IP地址
  • 验证消息真实性
  • 服务器接收实现
  • 客户端响应相关接口
  • 带参数的二维码
  • 用户管理
  • 素材管理
  • 菜单管理
  • 消息模板发送
  • web授权机制
  • JSSDK
  • 微信支付(扫码支付/公众号浏览器支付)
  • 企业付款到零钱包
  • 现金红包

微信小程序

  • 获取接口调用凭证
  • 小程序码
  • 小程序的微信支付
  • 小程序模板
  • 小程序客服消息
  • 内容安全

开源协议(License)

MIT