微信公众号接口配置验证URL

Posted wqy的笔记

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微信公众号接口配置验证URL相关的知识,希望对你有一定的参考价值。

/**
     * 审核填写的URL
     */
    public function checkUrl(){
        //获得参数 signature nonce token timestamp echostr

        $nonce     = $_GET(‘nonce‘);
        $token     = ‘sudi‘;
        $timestamp = $_GET(‘timestamp‘);
        $echostr   = $_GET(‘echostr‘);
        $signature = $_GET(‘signature‘);
        //形成数组,然后按字典序排序

        $array = array($nonce, $timestamp, $token);
        sort($array);
        //拼接成字符串,sha1加密 ,然后与signature进行校验
        $str = sha1( implode( $array ) );
        if( $str  == $signature && $echostr ){
            //第一次接入weixin api接口的时候
            echo  $echostr;
            exit;
        }else{
            $this->reponseMsg();
        }

    }

 

以上是关于微信公众号接口配置验证URL的主要内容,如果未能解决你的问题,请参考以下文章