<?php
//装载模板文件
include_once("wx_tpl.php");
//获取微信发送数据
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
//返回回复数据
if (!empty($postStr)){
//解析数据
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
//发送消息方 ID
$fromUsername = $postObj->FromUserName;
//接收消息方 ID
$toUsername = $postObj->ToUserName;
//消息类型
$form_MsgType = $postObj->MsgType;
//事件消息
if($form_MsgType=="event")
{
//获取事件类型
$form_Event = $postObj->Event;
//订阅事件
if($form_Event=="subscribe")
{
//回复欢迎文字消息
$msgType = "text";
$contentStr = "感谢您关注淇水朱华![愉快][玫瑰]";
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, time(), $msgType,
$contentStr);
echo $resultStr;
exit;
}
}
}
else
{
echo "";
exit;
}
评论5
最新资源