新增事件消息
This commit is contained in:
@@ -8,3 +8,41 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catchAdmin\wechat\controller;
|
||||
|
||||
use catchAdmin\wechat\repository\WechatUsersRepository;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\base\CatchRequest;
|
||||
use catcher\CatchResponse;
|
||||
use catcher\library\WeChat;
|
||||
use catcher\Utils;
|
||||
use think\facade\Console;
|
||||
use think\Request;
|
||||
|
||||
class Material extends CatchController
|
||||
{
|
||||
public function index(CatchRequest $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function read($id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function save(CatchRequest $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function update($id, Request $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -10,6 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace catchAdmin\wechat\controller;
|
||||
|
||||
use catchAdmin\wechat\library\messages\Factory;
|
||||
use catcher\base\CatchController;
|
||||
use catcher\library\WeChat;
|
||||
use think\Request;
|
||||
@@ -18,22 +19,17 @@ class Message extends CatchController
|
||||
{
|
||||
public function done(Request $request)
|
||||
{
|
||||
$app = WeChat::officialAccount();
|
||||
|
||||
if ($request->isPost()) {
|
||||
WeChat::officialAccount()->server->push(function ($message) {
|
||||
switch ($message['MsgType']) {
|
||||
case 'subscribe':
|
||||
return '收到事件消息';
|
||||
break;
|
||||
case 'unsubscribe':
|
||||
return '收到文字消息';
|
||||
break;
|
||||
case 'image':
|
||||
default:
|
||||
|
||||
$app->server->push(function ($message) {
|
||||
file_put_contents('root.txt', var_export($message, true), FILE_APPEND);
|
||||
if ($res = Factory::make($message)->reply()) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
}
|
||||
|
||||
$app->server->serve()->send();exit;
|
||||
}
|
||||
}
|
@@ -35,7 +35,6 @@ class Users extends CatchController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
dd(WeChat::officialAccount()->server->serve()->send());
|
||||
return CatchResponse::paginate($this->user->getList());
|
||||
}
|
||||
|
||||
@@ -64,11 +63,25 @@ class Users extends CatchController
|
||||
return CatchResponse::success($this->user->block($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 贴标签
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @param $id
|
||||
* @param Request $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function tag($id, Request $request)
|
||||
{
|
||||
return CatchResponse::success($this->user->tag($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户同步
|
||||
*
|
||||
* @time 2020年06月26日
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
Console::call('sync:users');
|
||||
|
@@ -1,43 +0,0 @@
|
||||
<?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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user