private function _handlePostObj($postObj) { $MsgType = strtolower((string) $postObj->MsgType); $result = array('from' => self::$_from_id = (string) htmlspecialchars($postObj->FromUserName), 'to' => self::$_my_id = (string) htmlspecialchars($postObj->ToUserName), 'time' => (int) $postObj->CreateTime, 'type' => (string) $MsgType); if (property_exists($postObj, 'MsgId')) { $result['id'] = $postObj->MsgId; } switch ($result['type']) { case 'text': $result['content'] = (string) $postObj->Content; // Content 消息内容 break; case 'location': $result['X'] = (double) $postObj->Location_X; // Location_X 地理位置纬度 $result['Y'] = (double) $postObj->Location_Y; // Location_Y 地理位置经度 $result['S'] = (double) $postObj->Scale; // Scale 地图缩放大小 $result['I'] = (string) $postObj->Label; // Label 地理位置信息 break; case 'image': $result['url'] = (string) $postObj->PicUrl; // PicUrl 图片链接,开发者可以用HTTP GET获取 $result['mid'] = (string) $postObj->MediaId; // MediaId 图片消息媒体id,可以调用多媒体文件下载接口拉取数据。 break; case 'video': $result['mid'] = (string) $postObj->MediaId; // MediaId 图片消息媒体id,可以调用多媒体文件下载接口拉取数据。 $result['thumbmid'] = (string) $postObj->ThumbMediaId; // ThumbMediaId 视频消息缩略图的媒体id,可以调用多媒体文件下载接口拉取数据。 break; case 'link': $result['title'] = (string) $postObj->Title; $result['desc'] = (string) $postObj->Description; $result['url'] = (string) $postObj->Url; break; case 'voice': $result['mid'] = (string) $postObj->MediaId; $result['format'] = (string) $postObj->Format; if (property_exists($postObj, Recognition)) { $result['txt'] = (string) $postObj->Recognition; } break; case 'event': $result['event'] = strtolower((string) $postObj->Event); switch ($result['event']) { case 'subscribe': case 'scan': if (property_exists($postObj, EventKey)) { $result['key'] = str_replace('qrscene_', '', (string) $postObj->EventKey); $result['ticket'] = (string) $postObj->Ticket; } break; case 'location': $result['la'] = (string) $postObj->Latitude; $result['lo'] = (string) $postObj->Longitude; $result['p'] = (string) $postObj->Precision; break; case 'click': $result['key'] = (string) $postObj->EventKey; break; } } return $result; }
private function _handlePostObj($postObj) { $MsgType = strtolower((string) $postObj->MsgType); $result = array('from' => self::$_from_id = (string) htmlspecialchars($postObj->FromUserName), 'to' => self::$_my_id = (string) htmlspecialchars($postObj->ToUserName), 'time' => (int) $postObj->CreateTime, 'type' => (string) $MsgType); if (property_exists($postObj, 'MsgId')) { $result['id'] = $postObj->MsgId; } switch ($result['type']) { case 'text': $result['content'] = (string) $postObj->Content; // Content 消息内容 break; case 'location': $result['X'] = (double) $postObj->Location_X; // Location_X 地理位置纬度 $result['Y'] = (double) $postObj->Location_Y; // Location_Y 地理位置经度 $result['S'] = (double) $postObj->Scale; // Scale 地图缩放大小 $result['I'] = (string) $postObj->Label; // Label 地理位置信息 break; case 'image': $result['url'] = (string) $postObj->PicUrl; // PicUrl 图片链接,开发者可以用HTTP GET获取 $result['mid'] = (string) $postObj->MediaId; // MediaId 图片消息媒体id,可以调用多媒体文件下载接口拉取数据。 break; case 'video': $result['mid'] = (string) $postObj->MediaId; // MediaId 图片消息媒体id,可以调用多媒体文件下载接口拉取数据。 $result['thumbmid'] = (string) $postObj->ThumbMediaId; // ThumbMediaId 视频消息缩略图的媒体id,可以调用多媒体文件下载接口拉取数据。 break; case 'link': $result['title'] = (string) $postObj->Title; // 消息标题 $result['desc'] = (string) $postObj->Description; // 消息描述 $result['url'] = (string) $postObj->Url; // 消息链接 break; case 'voice': $result['mid'] = (string) $postObj->MediaId; // 语音消息媒体id,可以调用多媒体文件下载接口拉取该媒体 $result['format'] = (string) $postObj->Format; // 语音格式:amr if (property_exists($postObj, Recognition)) { $result['txt'] = (string) $postObj->Recognition; // 语音识别结果,UTF8编码 } break; case 'event': $result['event'] = strtolower((string) $postObj->Event); // 事件类型,subscribe(订阅)、unsubscribe(取消订阅)、CLICK(自定义菜单点击事??? switch ($result['event']) { // case 'unsubscribe': // 取消订阅 case 'subscribe': // 订阅 // 订阅 case 'scan': // 扫描二维码 if (property_exists($postObj, EventKey)) { // 扫描带参数二维码事件 $result['key'] = str_replace('qrscene_', '', (string) $postObj->EventKey); // 事件KEY值,qrscene_为前缀,后面为二维码的参数值 $result['ticket'] = (string) $postObj->Ticket; } break; case 'location': // 上报地理位置事件 $result['la'] = (string) $postObj->Latitude; // 地理位置纬度 $result['lo'] = (string) $postObj->Longitude; // 地理位置经度 $result['p'] = (string) $postObj->Precision; // 地理位置精度 break; case 'click': // 自定义菜单事件 $result['key'] = (string) $postObj->EventKey; // 事件KEY值,与自定义菜单接口中KEY值对??? break; case "masssendjobfinish": // 高级群发接口 $result['id'] = (string) $postObj->MsgID; // 群发的消息ID $result['status'] = (bool) 'send success' === $postObj->Status; // 群发结果 $result['msg'] = (string) self::$ERRCODE_MAP[$postObj->Status]; // TotalCount >= FilterCount // FilterCount = SentCount + ErrorCount $result['total'] = (string) $postObj->TotalCount; // group_id下粉丝数;或者openid_list中的粉丝数 $result['fact'] = (string) $postObj->FilterCount; // 实际发送的粉丝数(部分设置黑白名单) $result['hit'] = (string) $postObj->SentCount; // 发送成功的粉丝数 $result['miss'] = (string) $postObj->ErrorCount; // 发送失败的粉丝数 break; } } return $result; }