php - 微信接入服务器验证的疑问
本文介绍了php - 微信接入服务器验证的疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
请问是不是这样一个流程的 微信用户每次发送信息给公众号 微信服务器都需要验证服务器的有效性
echostr 这个字段什么时候返回呢
解决方案
if (isset($_GET['echostr'])) {
if($this->checkSignature()) {
echo $_GET['echostr'];
exit;
}
} else {
$this->responseMsg();
}
//微信验证
private function checkSignature(){
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = TOKEN;
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr);
$tmpStr = implode($tmpArr);
$tmpStr = sha1($tmpStr);
if($tmpStr == $signature){
return true;
}
return false;
}
这篇关于php - 微信接入服务器验证的疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文