Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

区分指令回调与数据回调 #263

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 62 additions & 40 deletions open-work/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,71 @@ SDK 默认会处理事件 `suite_ticket` ,并会缓存 `suite_ticket`
$server = $app->server;

$server->push(function ($message) {
switch ($message['InfoType']) {
//推送suite_ticket
case 'suite_ticket':
break;
//授权成功通知
case 'create_auth':
break;
//变更授权通知
case 'cancel_auth':
break;
//通讯录事件通知
case 'change_contact':
switch ($message['ChangeType']){
case 'create_user':
return '新增成员事件';
break;
case 'update_user':
return '更新成员事件';
break;
case 'delete_user':
return '删除成员事件';
break;
case 'create_party':
return '新增部门事件';
break;
case 'update_party':
return '更新部门事件';
break;
case 'delete_party':
return '删除部门事件';
break;
case 'update_tag':
return '标签成员变更事件';
break;
}
break;
default:
return 'fail';
break;
//指令回调
if (isset($message['InfoType'])) {
switch ($message['InfoType']) {
//推送suite_ticket
case 'suite_ticket':
break;
//授权成功通知
case 'create_auth':
break;
//变更授权通知
case 'cancel_auth':
break;
//通讯录事件通知
case 'change_contact':
switch ($message['ChangeType']) {
case 'create_user':
return '新增成员事件';
break;
case 'update_user':
return '更新成员事件';
break;
case 'delete_user':
return '删除成员事件';
break;
case 'create_party':
return '新增部门事件';
break;
case 'update_party':
return '更新部门事件';
break;
case 'delete_party':
return '删除部门事件';
break;
case 'update_tag':
return '标签成员变更事件';
break;
}
break;
default:
return 'fail';
break;
}
}

//数据回调
if(isset($message['MsgType'])){
switch ($message['MsgType']) {
case 'event':
return '事件消息';//详情 https://work.weixin.qq.com/api/doc/90001/90143/90376#%E5%88%A0%E9%99%A4%E6%88%90%E5%91%98%E4%BA%8B%E4%BB%B6
break;
case 'text':
return '文本消息';//详情 https://work.weixin.qq.com/api/doc/90001/90143/90375#%E5%9B%BE%E7%89%87%E6%B6%88%E6%81%AF
break;
case 'image':
return '图片消息';
break;
//等等...不再一一举例
default:
return '其他消息';
break;
}
}

});
$response = $server->serve();
$response->send();

```