微信公众号token认证失败(TP3.2已解决)

 

要注意以下两点:

1、我这边token验证失败关键点就在于 header('content-type:text'); 和  ob_clean();   这2个要加上!

2、URL指向的方法页要确保是UTF-8 无BOM格式,可以用Notepad更改编码格式

 

    /**
     * 验证token
     */
    public function echostr(){

        $signature=$_GET["signature"];
        $timestamp=$_GET["timestamp"];
        $nonce=$_GET["nonce"];
        $echostr  = $_GET['echostr'];
        $token = 'aifFWSjhtu19ukNUmg6GzIxpDa46Ggi';

        $tmpArr = array($token,$timestamp, $nonce);
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode('',$tmpArr);
        $tmpStr = sha1($tmpStr);

        if($tmpStr==$signature && $echostr){
            header('content-type:text');
            ob_clean();
            echo $echostr;exit();
        }else{
            $this->reponseMsg();
        }
    }

 

如需转载请标记本文链接!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值