微信测试号–接口配置信息验证

public function index()
{
    $nonce     = $_GET['nonce'];
    $token     = '你的Token';
    $timestamp = $_GET['timestamp'];
    $echostr   = $_GET['echostr'];
    $signature = $_GET['signature'];
    //形成数组,然后按字典序排序
    $array = array();
    $array = array($nonce, $timestamp, $token);
    sort($array);
    //拼接成字符串,sha1加密 ,然后与signature进行校验
    $str = sha1implode( $array ) );
    if( $str == $signature && $echostr ){
        //第一次接入weixin api接口的时候
        echo  $echostr;
        exit;
    }
}

原文链接:微信测试号–接口配置信息验证

个人博客:www.liusongs.com

猜你喜欢

转载自blog.csdn.net/qq_35630665/article/details/87862448