很久没碰公众号开发了 今天帮别人开发公众号 重新记录一下
/** * 验证方法 * @return bool */ function checkSignature(){ $signature = $_GET["signature"]; $tmpArr = [ \'timestamp\' => $_GET["timestamp"], \'nonce\' => $_GET["nonce"], \'token\' => \'xxx\', ]; sort($tmpArr); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $signature == $tmpStr ){ return $_GET[\'echostr\']; }else{ return false; } } $res = checkSignature(); if($res){ echo $res; }
写到一个可以访问的php文件里 然后将这个php 文件的访问地址 填到 验证url 里面 填写其它资料 提交就可以了