Wechat Component For Yii2
Wechat Component For Yii2, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist peijunyang/yii2-wechat "*"
or add, (*4)
"peijunyang/yii2-wechat": "*"
to the require section of your composer.json
file., (*5)
Usage
Once the extension is installed, simply modify your application configuration as follows:, (*6)
return [
...
'components' => [
....
'wechat' => [
'class' => 'peijunyang\wechat\Component',
'config' => [
'type'=>'common', // 微信账号类型, common 普通, qy 企业
'token'=>'tokenaccesskey', //填写你设定的key
'encodingaeskey'=>'encodingaeskey', //填写加密用的EncodingAESKey
'appid'=>'wxdk1234567890', //填写高级调用功能的app id, 请在微信开发模式后台查询
'appsecret'=>'xxxxxxxxxxxxxxxxxxx' //填写高级调用功能的密钥
],
]
],
];
Use it in your code by :, (*7)
$weObj = Yii::$app->wechat->getWechat(); //获取wechat对象实例
//TODO:调用$weObj各实例方法
For full details on usage, see the api wiki., (*8)