2020-06-22 12:36:25 +08:00
|
|
|
|
<?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 ]
|
|
|
|
|
// +----------------------------------------------------------------------
|
2020-06-24 09:10:24 +08:00
|
|
|
|
namespace catchAdmin\wechat\controller;
|
|
|
|
|
|
2020-06-26 22:08:01 +08:00
|
|
|
|
use catchAdmin\wechat\library\messages\Factory;
|
2020-06-24 09:10:24 +08:00
|
|
|
|
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-24 09:10:24 +08:00
|
|
|
|
|
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-24 09:10:24 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-06-26 22:08:01 +08:00
|
|
|
|
|
|
|
|
|
$app->server->serve()->send();exit;
|
2020-06-24 09:10:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|