微信开发之一:微信绑定

<?php
	//1,将timestamp,nonce,token按照字典排序
	$timestamp = $_GET['timestamp'];
	$nonce = $_GET['nonce'];
	$token = 'weixin';
	$signature = $_GET['signature'];
	$array = array($timestamp,$nonce,$token); 
	sort($array);
	//2,将排序后的三个参数进行拼接后用sha1加密
	$tmpstr = implode('',$array);//join
	$tmpstr = sha1($tmpstr);
	//3,将机密后的字符串与signature进行对比,判断请求是否来自微信
	if($tmpstr == $signature){
		echo $_GET['echostr'];
		exit;
	}

猜你喜欢

转载自blog.csdn.net/weixin_36171533/article/details/80474158