WeChat public platform-WeChat service number today reply to custom PHP, found that the company's service number does not work properly, but with its own public number can automatically reply to the message

Source: Internet
Author: User
Tags cdata sha1 sprintf
Today to get the service number of the message reply to the custom PHP, found that the company's service number does not work properly, but with their own public number can automatically reply to the message
What would be the cause of this situation, please?


  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 0 
     %s 
 
     
     %s 
 
     
     %s 
 
     
     %s 
 
                             
                         
                         
                         
                         
                         
                         

   
  ";            $msgType = "text"; $CONTENTSTR = Date ("Y-m-d h:i:s", Time ()). " \ n '. '            Hello ';            $RESULTSTR = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time, $msgType, $CONTENTSTR);        Echo $resultStr;            }else{echo "";        Exit }}}?>

Reply content:

Today to get the service number of the message reply to the custom PHP, found that the company's service number does not work properly, but with their own public number can automatically reply to the message
What would be the cause of this situation, please?


  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 0 
     %s 
 
     
     %s 
 
     
     %s 
 
     
     %s 
 
                             
                         
                         
                         
                         
                         
                         

   
  ";            $msgType = "text"; $CONTENTSTR = Date ("Y-m-d h:i:s", Time ()). " \ n '. '            Hello ';            $RESULTSTR = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time, $msgType, $CONTENTSTR);        Echo $resultStr;            }else{echo "";        Exit }}}?>

You can first look at whether your public number configuration information is configured in the code as a company's information

Resolved, is two public number in the binding URL when the choice of mode is not the same, select ' Safe mode ' will error, select ' Civilized mode ' can be accessed normally.

  • Related Article

    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.