调整架构,新增微信模块服务

This commit is contained in:
JaguarJack
2020-06-24 09:10:24 +08:00
parent 0e7453a6fe
commit 2d95212973
6 changed files with 109 additions and 16 deletions

View File

@@ -8,3 +8,36 @@
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catchAdmin\wechat\controller;
use catcher\base\CatchController;
use think\facade\Log;
use think\Request;
use catcher\library\WeChat as WechatServer;
class Wechat extends CatchController
{
public function index(Request $request)
{
$app = WechatServer::officialAccount();
$app->server->push(function ($message) {
switch ($message['MsgType']) {
case 'event':
file_put_contents(base_path() . DIRECTORY_SEPARATOR .'root.txt', json_encode((array)$message));
return '收到事件消息了吗😄';
break;
case 'text':
return '收到文字消息';
break;
case 'image':
break;
default:
}
return '结束了';
});
$app->server->serve()->send();exit;
}
}