<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
//echo "1112";
//获得参数signature,nonce,token,timestamp,echostr
$nonce = $_GET['nonce'];
$token = 'xiaojia';
$timestamp = $_GET['timestamp'];
$echostr = $_GET['echostr'];
$signature = $_GET['signature'];
//形成数组,然后按字典序排序
$array = array();
$array = array($timestamp,$nonce,$token);
sort($arr);
//拼接成字符串,然后与signature进行校验
$str = sha1(implode($array));
if($str == $signature){
echo $str;
exit;
}
}
} 最佳答案