<?php
//获得基本参数
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$token = 'weixin20190715';
$signature = $_GET['signature'];
//形成数组,按字典序排序
$array = array();
$array = array($timestamp,$nonce,$token);
sort($array);
//拼接成字符串,sha1加密,然后和signature进行校验
$tmpstr = implode('',$array);
$tmpstr = sha1($tmpstr);
if( $tmpstr == $signature ){
//销毁输出缓冲区就可以绑定成功了 这一个问题让我耽误了几个小时 真是浪费时间
ob_clean();
echo $_GET['echostr'];
exit;
}
我是单独给他配了一个环境,做微信公众号接口信息配置的,这个方式正式的和测试公众号都可以认证,已测试有效