1、安装插件后设置信息
上传证书在data/cert/wxpay下面
对应好名称 如果修改了名称需要在代码里修改在RedPacketCommon文件的curlPostSsl方法里面
设置好微信设置
在微信回调地址的代码中加上以下代码
if (!$this->_checkSignature()) { die('非法操作!'); } $redPacketCommon = new RedPacketCommon(); $input = $this->request->getInput(); $data = $redPacketCommon->xmlToArray($input); //调用发送红包 if ($data['MsgType'] == 'event') { $redPacketCommon->sendRedPacket($data); } private function _checkSignature() { $signature = $this->request->param("signature"); $timestamp = $this->request->param("timestamp"); $nonce = $this->request->param("nonce"); $tmpArr = ['token123', $timestamp, $nonce]; sort($tmpArr, SORT_STRING); $tmpStr = implode($tmpArr); $tmpStr = sha1($tmpStr); if ($signature == $tmpStr) { return true; } else { return false; } } 我的代码是:
记得修改你设置的token的值,我设置的测试值是:token123 $tmpArr = ['token123', $timestamp, $nonce];
ThinkCMF模板插件交流群:550851374 ,领取阿里云1000通用代金券