微信接口接入

<?php
//GET请求来自微信服务器发送的数据

//加密签名
$signature = $_GET["signature"];
//时间戳
$timestamp = $_GET["timestamp"];
//随机数
$nonce = $_GET["nonce"];
//随机字符串
$echostr = $_GET["echostr"];
//定义TOKEN
define('TOKEN','liuyuanshan');
//组装数组
$tmpArr = array(TOKEN, $timestamp, $nonce);
//对数组进行字典序排序
sort($tmpArr, SORT_STRING);
//数组转字符串拼接
$tmpStr = join($tmpArr);
//sha1加密
$tmpStr = sha1( $tmpStr );
//与拼接的加密签名比较
if( $tmpStr == $signature ){
        echo $echostr;
    }else{
        return 'error';
    }
发布了40 篇原创文章 · 获赞 0 · 访问量 689

猜你喜欢

转载自blog.csdn.net/weixin_39218464/article/details/103938842