Wechat official account can not reply to the message, ask for advice!

I just started to learn the development of official account. According to the tutorials of Mutu.com, the previous server verification part has been successful, and the latter reply part can not be received on Wechat. I would like to ask God for help to see where there is a problem. Thank you very much!

<?php
//
//1. 
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = "weixin";
$signature = $_GET["signature"];
$array = array($timestamp,$nonce,$token);
sort($array);

//2. 
$tmpstr = implode("",$array);
$tmpstr = sha1($tmpstr);

//3. 
if ($tmpstr == $signature AND $_GET["echostr"]) {
echo $_GET["echostr"];
exit;
}else{
responseMsg();
}

//

public function responseMsg(){
    $postArr = $GLOBALS["HTTP_RAW_POST_DATA"];
    $postObj = simplexml_load_string($postArr);
    
    if (strtolower($postObj->MsgType) == "event"){
        if (strtolower($postObj->Event) == "subscribe"){
        
            $toUser = $postObj->FromUserName;
            $fromUser = $postObj->toUserName;
            $time = time();
            $msgType = "text";
            $content = "";
            $template = "<xml> 
            <ToUserName>< ![CDATA[%s] ]></ToUserName> 
            <FromUserName>< ![CDATA[%s] ]></FromUserName> 
            <CreateTime>%s</CreateTime> 
            <MsgType>< ![CDATA[%s] ]></MsgType> 
            <Content>< ![CDATA[%s] ]></Content> 
            </xml>";
            $info = sprintf($template, $toUser, $fromUser, $time, $msgType, $content);
            echo $info;
        }
    }
}
?>

the function of your reply message is in the wrong position and should not be written in 3. The else, in the comparison should be written after


if and remove the else after the server verification section, and just call that function directly!


Thank you very much for your help. Later, I found that the reason for the error is that there is an extra space on each side of the exclamation mark in the reply template, resulting in a failure to reply successfully. Thank you both!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2b6b1-2ba78.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2b6b1-2ba78.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?