public function index()
{
$signature = (isset($_GET['signature']) ? $_GET['signature'] : '');//微信加密签名
$timestamp = (isset($_GET['timestamp']) ? $_GET['timestamp'] : '');//时间戳
$nonce = (isset($_GET['nonce']) ? $_GET['nonce'] : '');//随机数
$token ='123456'; //自己设置的Token
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);//检验第一步
$tmpStr = implode($tmpArr);//检验第二步
$tmpStr = sha1($tmpStr);//检验第二步
if($signature==$tmpStr){//检验第三补
exit($_GET['echostr']); //通过检验,鸳鸯返回echostr参数内容
}else{
exit($tmpStr);//未通过检验,自定义操作
}
}
再说下微信官方给的那个认证很不好用,就是不行,这个认证还好能用。
网友评论