今天弄微信服务号的消息回复自定义php,发现用公司的服务号不能正常运行,但是用自己的公众号却可以自动回复消息
请问这种情况会是什么造成的
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 = %s0; $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; } }}?>
回复内容: 今天弄微信服务号的消息回复自定义php,发现用公司的服务号不能正常运行,但是用自己的公众号却可以自动回复消息
请问这种情况会是什么造成的
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 = %s0; $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; } }}?>
可以先看一下是否把自己的微信公众号配置信息当成公司的信息配置到了代码中
已解决,是两个公众号在绑定url的时候 选择的模式不一样,选择'安全模式'会报错,选择'文明模式'能正常访问。