yii2 wx
1.3.6
A WeChat SDK serving yii2 (official account, mini program, open platform and enterprise WeChat)
$ composer require " abei2017/yii2-wx " -vvv
It is recommended that the configuration parameters be stored in the configuration file of yii2. For example, the basic version of yii2 can be configured as follows
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 ' => '' ,
],
]
]
];
For configuration, please do not modify the key value of the data.
yii2-wx adopts the idea of a single interface driver function. For example, the following code will generate a WeChat QR code with parameters.
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秒
WeChat public account
WeChat applet
MIT