vaild();
function (){
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$echostr = $_GET["echostr"];
$token = TOKEN;
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature && echostr){
echo $echostr;
}else{
return false;
}
}
responseMsg();
function responseMsg(){
$info = file_get_contents("php://input");
$postObj = simplexml_load_string($info);
$toUser = $postObj->FromUserName;
$fromUser = $postObj->ToUserName;
$time = time();
$msgType = $postObj->MsgType;
$content = '你好啊';
$template = '<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml>';
$response = sprintf($template,$toUser,$fromUser,$time,$msgType,$content);
file_put_contents('./response.html', $response);
echo $response;
}
近期评论