/**
* 微信公众号对接服务器Token验证类
* h5tpl.com
* MpCheck::check($token);
* 下面写自己的逻辑
* @package wechat
*/
class MpCheck
{
/**
* 外部使用
* @param $token
*/
public static function check($token)
{
if(self::checkSignature($token)){
exit($_GET["echostr"]);
}
}
/**
* 请求验证
* @param $token
* @return bool
*/
private static function checkSignature($token)
{
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$tmpArr = array($token, $timestamp, $nonce);
// use SORT_STRING rule
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
return true;
}else{
return false;
}
}
}
宠物免费领养小程序,欢迎来踩