/**
* 相关回复
*/
public function responseMsg()
{
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];//返回回复数据
if (!empty($postStr))
{
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA,',',');
$fromUsername = $postObj->FromUserName;//发送消息方ID
$toUsername = $postObj->ToUserName;//接收消息方ID
$keyword = trim($postObj->Content,',',');//用户发送的消息
$times = time(,',',');//发送时间
$MsgType = $postObj->MsgType;//消息类型
$msgType = "text";
if($MsgType=='event')
{
$MsgEvent = $postObj->Event;//获取事件类型
if ($MsgEvent=='subscribe')
{
//订阅事件
}
elseif ($MsgEvent=='CLICK')
{
//点击事件
$EventKey = $postObj->EventKey;//菜单的自定义的key值,可以根据此值判断用户点击了什么内容,从而推送不同信息
switch($EventKey)
{
case "V1001_TODAY_MUSIC" :
//要返回相关内容
break;
case "V1001_TODAY_SINGER" :
//要返回相关内容
break;
case "V1001_HELLO_WORLD" :
//要返回相关内容
break;
case "V1001_GOOD" :
//要返回相关内容
break;
}
}
}
$textTpl = "
%s
0
";
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $times, "text", "这里是要说的内容",',',');
}
else
{
echo '没有任何消息传递';
}
}
关键字词:

