微信后台开发学习笔记(3)

重构验证接口python

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;
	}
}
相关文章
相关标签/搜索