1: <?php
2: /**
3: * WxRobot - 事件处理类
4: *
5: * @author midoks
6: * @category WxRobot
7: * @package WxRobot/Cmd
8: * @since 5.3.0
9: */
10:
11: /**
12: * WxRobot_Cmd_Event 事件命令处理类
13: */
14: class WxRobot_Cmd_Event{
15:
16: /**
17: * WxRobot_Cmd_Text Instance
18: */
19: public static $_instance = null;
20:
21: /**
22: * WxRobot 文本消息处理类实例化
23: *
24: * @return WxRobot_Cmd_Text instance
25: */
26: public static function instance(){
27: if( is_null (self::$_instance)){
28: self::$_instance = new self();
29: }
30: return self::$_instance;
31: }
32:
33: /**
34: * 构造函数
35: */
36: public function __construct(){
37: $this->options = get_option(WEIXIN_ROBOT_OPTIONS);
38: $this->wxSdk = WxRobot_SDK::instance();
39: $this->extends = WxRobot_Extends::instance();
40: $this->info = wx_request_array();
41: }
42:
43: /**
44: * 订阅事件
45: *
46: * @return xml|bool
47: */
48: public function subscribeEvent(){
49: if($wp_plugins = $this->extends->dealwith('subscribe', $this->info)){
50: return $wp_plugins;
51: }
52:
53: $s = $this->options['subscribe'];
54: if(!empty($s)){
55: return $this->wxSdk->toMsgText($s);
56: }
57:
58: return false;
59: }
60:
61: /**
62: * 取消订阅时间
63: *
64: * @return mixed
65: */
66: public function unsubscribeEvent(){
67: return $this->wxSdk->toMsgText('谢谢你的使用!!!');
68: }
69:
70: /**
71: * 上报地址事件(服务号开启后,会每隔5分钟回复一次)
72: *
73: * @return mixed
74: */
75: public function LOCATIONEvent(){
76: //基本数据
77: $info['Latitude'] = $this->info['Latitude'];
78: $info['Longitude'] = $this->info['Longitude'];
79: $info['Precision'] = $this->info['Precision'];
80:
81: if($wp_plugins = $this->extends->dealwith('location', $info)){
82: return $wp_plugins;
83: }
84: }
85:
86: /**
87: * 用户已关注时的事件推送
88: *
89: * @return xml
90: */
91: public function scanEvent(){
92: if($wp_plugins = $this->extends->dealwith('scan', $this->$info)){
93: return $wp_plugins;
94: }
95: }
96:
97: /**
98: * 模版消息返回信息(暂时不处理)
99: *
100: * @return void
101: */
102: public function TEMPLATESENDJOBFINISHEvent(){}
103:
104: /**
105: * 事件推送群发结果(暂时不处理)
106: *
107: * @return void
108: */
109: public function MASSSENDJOBFINISHEvent(){}
110: }
111: ?>
112: