
下面代码放到你填写的url地址里面就好了
public function checksignature()
{
$signature = $this->request->get('signature');
$timestamp = $this->request->get('timestamp');
$nonce = $this->request->get('nonce');
$echostr = $this->request->get('echostr');
$token = config('site.message_token');
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode($tmpArr);
$tmpStr = sha1($tmpStr);
if ($tmpStr == $signature ) {
return $echostr;
} else {
return false;
}
}
该代码段是一个用于检查微信公众号API请求签名的PHP函数。它接收signature,timestamp,nonce和echostr参数,结合固定token进行排序和SHA1加密,然后对比签名以验证请求的合法性。如果签名匹配,返回echostr;否则返回false。
4225

被折叠的 条评论
为什么被折叠?



