ThirdMessageController.class.php
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* 由Uc中转的三方消息回调
* User: zhuxun37
* Date: 16/8/11
* Time: 下午3:41
*/
namespace Frontend\Controller\Callback;
use Common\Common\Cache;
use Think\Log;
use Common\Common\User;
use Common\Common\Msg;
class ThirdMessageController extends AbstractController
{
public function before_action($action = '')
{
if (! parent::before_action($action)) {
return false;
}
// 微信消息 Json 解析
$this->callBackData['wxMessage'] = json_decode($this->callBackData['wxMessage'], true);
Log::record(sprintf('---%s %s ThirdMessage START---', QY_DOMAIN, APP_IDENTIFIER), Log::INFO);
Log::record(var_export($this->callBackData, true), Log::INFO);
Log::record(sprintf('---%s %s ThirdMessage END ---', QY_DOMAIN, APP_IDENTIFIER), Log::INFO);
return true;
}
/**
* 三方消息回调
*
* wxMessage 为第三方消息内容, $this->callBackData 格式如下:
* {
* "msg":"成功",
* "code":"SUCCESS",
* "wxMessage": {
* "agentId":114,
* "toUserName":"wx276cb16432f0bdd9",
* "fromUserName":"zhuxun37",
* "createTime":1470972131,
* "msgType":"text",
* "content":"讲话稿",
* "msgId":4617283198342698634
* },
* "memUid":"78D547B77F00000162CAAD4E526287C7",
* "epEnumber":"t5thr"
* }
*
* @return bool
*/
public function Index()
{
$this->clearCache();
exit('SUCCESS');
}
/**
* 清理缓存应用权限缓存
*
* @return bool
*/
protected function clearCache()
{
$cache = &Cache::instance();
// 人员关注事件
if ($this->callBackData['wxMessage']['msgType'] == cfg('UC_CALLBACK_MSG_TYPE_SUBSCRIBE')) {
// 清除应用权限信息
$cache->set('Common.Jurisdiction', null);
}
return true;
}
}