服务端验证微信token
header(‘Content-type:text‘); define("TOKEN", "weixin"); $signature = $_GET[‘signature‘];//微信待验证参数 $timestamp = $_GET[‘timestamp‘];//时间戳 $nonce = $_GET[‘nonce‘];//随机数 $token = TOKEN;//token 公众号后台配置的 $tmpArr = array($timestamp,$nonce,$token); sort($tmpArr); $tmpStr = implode($tmpArr); $tmpStr = sha1($tmpStr); if($tmpStr == $signature){//验证 echo $_GET[‘echostr‘];//记得 输出该参数 }else{ return false; }