• 接入微信公众账号API--验证的代码实现


    <?php
    
    //1、将timestamp, nonce, token 按字典序排序
    $timestamp = $_GET['timestamp'];
    $nonce = $_GET['nonce'];
    $token = 'weixin';   //你在公众平台上填写的token
    $signature = $_GET['signature'];
    $arr = array( $timestamp, $nonce, $token );
    sort($arr);
    
    //2、将排序后的3个参数拼接后用sha1加密
    $tmpstr = implode('', $arr);
    $tmpstr = sha1($tmpstr);
    
    //3、将加密后的字符串与signature进行对比,判断该请求是否来自微信
    if($tmpstr == $signature){
        echo $_GET['echostr'];
        exit;
    }
  • 相关阅读:
    【CSS】 布局之圣杯布局
    PHP函数
    spry菜单栏(二)
    正则表达式补充
    练习用php做表格
    PHP入门
    MySQL常用函数
    数据库习题
    总结
    Navicat
  • 原文地址:https://www.cnblogs.com/chenyingying0/p/12763501.html
Copyright © 2020-2023  润新知