WeChat public platform-get the message of WeChat service number to reply to the custom php today, and found that the service number of the company cannot run normally, but the user's public number can automatically reply to the message

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.