35 lines
1.3 KiB
PHP
Raw Normal View History

<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catchAdmin\wechat\controller;
2020-06-26 22:08:01 +08:00
use catchAdmin\wechat\library\messages\Factory;
use catcher\base\CatchController;
use catcher\library\WeChat;
use think\Request;
class Message extends CatchController
{
public function done(Request $request)
{
2020-06-26 22:08:01 +08:00
$app = WeChat::officialAccount();
2020-06-26 22:08:01 +08:00
if ($request->isPost()) {
$app->server->push(function ($message) {
file_put_contents('root.txt', var_export($message, true), FILE_APPEND);
if ($res = Factory::make($message)->reply()) {
return $res;
}
});
}
2020-06-26 22:08:01 +08:00
$app->server->serve()->send();exit;
}
}