微信公众平台后台配置的时候出现“token验证失败”,如图:
需要使用ob_clean();
,如下:
//检查签名 public function checktoken(){ $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $echostr= $_GET["echostr"]; $token = 'toreadinhuo'; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr, SORT_STRING); $tmpStr = implode($tmpArr); $tmpStr = sha1($tmpStr); if ($signature == $tmpStr ) { ob_clean(); echo $_GET['echostr']; } else { return false; } }
分类:PHP
标签: