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

ぐ巨炮叔叔 提交于 2020-02-29 18:52:06
/**
     * 审核填写的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();
        }

    }

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!