重构验证接口
public function index(){
//获得参数nonce token timestamp echostr signature
$nonce = $_GET['nonce'];
$token = 'weixin';
$timestamp = $_GET['timestamp'];
$echostr = $_GET['echort'];
$signature = $_GET['signature'];
//形成数组,按字典序排序
$array = array();
$array = array($timestamp,$nonce,$token);
sort($array);
//拼接成字符串,sha1加密,然后 与signature进行校验
$str = sha1(implode($array));
if($tmpstr ==$signature ){
echo $_GET['echostr'];
exit;
}
}