public function run() { $moreRequestMessage = getMoreRequestMessage(); $this->fromusername = $moreRequestMessage["fromusername"]; $this->tousername = $moreRequestMessage["tousername"]; $this->msgtype = $moreRequestMessage["msgtype"]; //是否开启菜单 if (!!$this->config->item("ismenu")) { $access_token = get_access_token(); createmenu($access_token); } //判断消息类型 switch ($this->msgtype) { case 'event': //判断事件类型 $this->event = $moreRequestMessage["event"]; $this->handleEventMessage($this->event); break; case 'text': $keyMessage = getKeyRequestTextMessage(); $content = $keyMessage['content']; $this->responseTextMessage($content); break; case 'image': $keyMessage = getKeyRequestImageMessage(); $picurl = $keyMessage['picurl']; $mediaid = $keyMessage['mediaid']; $this->responseImageMessage($picurl, $mediaid); break; case 'location': $keyMessage = getKeyRequestLocationMessage(); $location_x = $keyMessage['location_x']; $location_y = $keyMessage['location_y']; $scale = $keyMessage['scale']; $label = $keyMessage['label']; $this->responseLocationMessage($location_x, $location_y, $scale, $label); break; case 'link': $keyMessage = getKeyRequestLinkMessage(); $title = $keyMessage['title']; $description = $keyMessage['description']; $url = $keyMessage['url']; $this->responseLinkMessage($title, $description, $url); break; case 'voice': $keyMessage = getKeyRequestVoiceMessage(); $mediaid = $keyMessage['mediaid']; $format = $keyMessage['format']; $this->responseVoiceMessage($mediaid, $format); break; default: $this->responseUnknownMessage(); break; } }
public function run() { $moreRequestMessage = getMoreRequestMessage(); $this->fromusername = $moreRequestMessage["fromusername"]; $this->tousername = $moreRequestMessage["tousername"]; $this->msgtype = $moreRequestMessage["msgtype"]; //session保存fromusername $uid = array('fromusername' => $this->fromusername); $this->session->set_userdata($uid); //是否开启菜单 if (!!$this->config->item("ismenu")) { createmenu(); } //判断消息类型 switch ($this->msgtype) { case 'event': //判断事件类型 $this->event = $moreRequestMessage["event"]; $this->handleEventMessage($this->event); break; case 'text': $keyMessage = getKeyRequestTextMessage(); $content = $keyMessage['content']; $this->responseTextMessage($content); break; case 'image': $keyMessage = getKeyRequestImageMessage(); $picurl = $keyMessage['picurl']; $mediaid = $keyMessage['mediaid']; $this->responseImageMessage($picurl, $mediaid); break; case 'location': $keyMessage = getKeyRequestLocationMessage(); $location_x = $keyMessage['location_x']; $location_y = $keyMessage['location_y']; $scale = $keyMessage['scale']; $label = $keyMessage['label']; $this->responseLocationMessage($location_x, $location_y, $scale, $label); break; case 'link': $keyMessage = getKeyRequestLinkMessage(); $title = $keyMessage['title']; $description = $keyMessage['description']; $url = $keyMessage['url']; $this->responseLinkMessage($title, $description, $url); break; case 'voice': //开启语音转换 $keyMessage = getKeyRequestAdvancedVoiceMessage(); $mediaid = $keyMessage['mediaid']; $format = $keyMessage['format']; $recognition = $keyMessage['recognition']; $this->responseAdvancedVoiceMessage($mediaid, $format, $recognition); //接收普通消息 //$keyMessage=getKeyRequestVoiceMessage(); //$mediaid=$keyMessage['mediaid']; //$format=$keyMessage['format']; //$this->responseVoiceMessage($mediaid,$format); break; default: $this->responseUnknownMessage(); break; } }