php微信接口验证写法

时间:2016-02-20 14:32:36   收藏:0   阅读:280
<?php
    //获得接口认证
    $timestamp = $_GET[‘timestamp‘];
    $nonce = $_GET[‘nonce‘];
    $token = ‘weixin‘;
    $signature = $_GET[‘signature‘];
    //将参数字典化排序
    $tmpArr = array($timestamp,$nonce,$token);
    sort($tmpArr);
    $judgeArr = implode(‘‘,$tmpArr);
    $judge = sha1($judgeArr);
    //判断是否符合
    if($judge == $signature)
    {
        echo $_GET[‘echostr‘];
        exit;
    }

 

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!