个人微信小程序 消息推送服务器配置问题?
使用的代码贴上
<?php
printLog(json_encode($_GET));
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$echostr = $_GET["echostr"];
$token = "mytoken";
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
printLog("tmpStr:".$tmpStr);
printLog("signature:".$signature);
if( $tmpStr == $signature ){
echo $echostr;
}else{
echo false;
}
/**
* 打印数据
* [@param](/user/param) string $txt 日志记录
* [@param](/user/param) string $file 日志目录
* [@return](/user/return)
*/
function printLog($txt="",$file="ceshi.log"){
$myfile = fopen($file, "a+");
$StringTxt = "[".date("Y-m-d H:i:s")."]".$txt."\n";
fwrite($myfile, $StringTxt);
fclose($myfile);
}
?>
附上请求数据
[2020-10-01 14:30:21]{"signature":"32ecf5f3139e121e5d7e9c242924c8b02f3eb263","echostr":"664938171124940799","timestamp":"1601533823","nonce":"1688545518"}
[2020-10-01 14:30:21]tmpStr:32ecf5f3139e121e5d7e9c242924c8b02f3eb263
[2020-10-01 14:30:21]signature:32ecf5f3139e121e5d7e9c242924c8b02f3eb263
很明显 $tmpStr == $signature
可是依然是这个结果 Token校验失败,请检查确认
所以这玩意到底要怎么弄呀???求助!!!