【微信公众号】修改配置的时候提示token验证失败

  1. 首先要确定你填写的URL在外网可以访问,填写的URL精确到你要上传的那个文件名,如我的:http://www.域名/weixin/index.php
  2. 将下面的代码写到index.php里面
<?php
//1.将timestamp,nonce,toke按字典顺序排序
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$token = 'weixin';
$signature = $_GET['signature'];
$array = array($timestamp,$nonce,$token);
//2.将排序后的三个参数拼接之后用sha1加密
$tmpstr = implode('',$array);
$tmpstr = sha1($tmpstr);
//3.将加密后的字符串与signature进行对比,判断该请求是否来自微信
if($tmpstr == $signature){
    header('content-type:text');
    echo $_GET['echostr'];
    exit;
}

3.在网页浏览http://www.域名/weixin/index.php<什么都不会输出,不要着急>

4.在你修改配置的页面再次点击提交按钮,就会显示提交成功。<多试几次,有的时候可能是网络原因>

    

猜你喜欢

转载自blog.csdn.net/weixin_41728561/article/details/80451806