语音消息
<?php
class wxController extends grace{
public function index(){
$gracewechat = tool('graceWeChat');
$gracewechat->getMsg();
if($gracewechat->msgType == 'voice'){
/*
请注意,开通语音识别后,用户每次发送语音给公众号时,微信会在推送的语音消息XML数据包中,
增加一个Recognition字段(注:由于客户端缓存,开发者开启或者关闭语音识别功能,对新关注者立刻生效,
对已关注用户需要24小时生效。开发者可以重新关注此帐号进行测试。
*/
$graceWechat->reTextMsg('语音内容 : '.$graceWechat->msg->Recognition);
//下载语音素材可以利用 MediaId 字段
}
}
位置消息
<?php
class wxController extends grace{
public function index(){
$gracewechat= tool('graceWeChat');
$gracewechat->getMsg();
if($gracewechat->msgType == 'location'){
$gracewechat->reTextMsg('您的位置 : '.$gracewechat->msg->Label);
}
}
}
图片消息
<?php
class wxController extends grace{
public function index(){
$gracewechat = tool('graceWeChat');
$gracewechat->getMsg();
if($gracewechat->msgType == 'image'){
$gracewechat->reTextMsg('图片 : '.$gracewechat->msg->PicUrl);
}
}
}
说明
请参考微信公众号开发手册,根据消息类型及对应的数据结构进行更多消息的处理,手册地址:
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140453