公众号基本配置(token验证失败)|公众平台测试账号接口配置信息(token验证失败)

1.公众号基本配置(token验证失败)

valid();

class CallbackAPI {

    /**
     * 签名验证
     * @return [type] [description]
     */
     public function valid() {
        $echoStr = $_GET["echostr"];
        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];
        $token = TOKEN;
        //将token、timestamp、nonce按字典序排序
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr);
        $tmpStr = implode($tmpArr);
        //对tmpStr进行sha1加密
        $tmpStr = sha1($tmpStr);
        if($tmpStr == $signature){
            header('content-type:text');
            echo $echoStr;
            exit;
        }
    }
}

2.公众平台测试账号接口配置信息(token验证失败)

'.$signature.'-'.$timestamp.'-'.$nonce.'-'.$token, FILE_APPEND);
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode( $tmpArr );
        $tmpStr = sha1( $tmpStr );
        @file_put_contents('Public/checksing.html', '
'.$tmpStr.'--'.$echostr, FILE_APPEND); //进行比对 if( $signature ){ echo $echostr; }else{ return false; }

你可能感兴趣的:(PHP,THinkPHP,php)