Today, I got a message from the service number to reply to the custom php and found that the service number of the company could not run normally, however, you can use your own public account to automatically reply to the message. what is the cause of this situation? {code ...} get the message of service number reply custom php today, found that the service number of the company cannot run normally, but with their own public number can automatically reply to the message
What is the cause of this situation?
valid();}else{ $wechatObj->responseMsg();}class wechatCallbackapiTest{ public function valid() { $echoStr = $_GET["echostr"]; if($this->checkSignature()){ header('content-type:text'); echo $echoStr; exit; } } private function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr, SORT_STRING); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ){ return true; }else{ return false; } } public function responseMsg() { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; if (!empty($postStr)){ $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim($postObj->Content); $time = time(); $textTpl = "
%s
%s
%s
%s
%s
0
"; $msgType = "text"; $contentStr = date("Y-m-d H:i:s",time())."\n\n".'hello'; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; }else{ echo ""; exit; } }}?>
Reply content:
Get the message of service number reply custom php today, found that the service number of the company cannot run normally, but with their own public number can automatically reply to the message
What is the cause of this situation?
valid();}else{ $wechatObj->responseMsg();}class wechatCallbackapiTest{ public function valid() { $echoStr = $_GET["echostr"]; if($this->checkSignature()){ header('content-type:text'); echo $echoStr; exit; } } private function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr, SORT_STRING); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ){ return true; }else{ return false; } } public function responseMsg() { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; if (!empty($postStr)){ $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim($postObj->Content); $time = time(); $textTpl = "
%s
%s
%s
%s
%s
0
"; $msgType = "text"; $contentStr = date("Y-m-d H:i:s",time())."\n\n".'hello'; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; }else{ echo ""; exit; } }}?>
Check whether your public account configuration information is configured in the code as the company information.
It has been fixed that the two public numbers are different in the mode selected when the URL is bound. if you select 'security mode', an error is returned. if you select 'civilized mode', the access will be normal.