同样的代码在另一套程序里面没有问题.求大神解惑,在线等.谢谢
代码:
public function WXMain()
{
if (isset($_GET['echostr'])) {
$this->valid();
} else {
$this->responseMsg();
}
}
public function valid()
{
$echoStr = $_GET["echostr"];
if($this->checkSignature()){
\Think\Log::write($echoStr);
echo $echoStr;
exit;
}
}
private function checkSignature()
{
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = C('TOKEN');
\Think\Log::write('token=>'.$token);
$tmpArr = array(
$token,
$timestamp,
$nonce
);
sort($tmpArr);
$tmpStr = implode($tmpArr);
$tmpStr = sha1($tmpStr);
\Think\Log::write('tmpStr=>'.$tmpStr);
\Think\Log::write('signature=>'.$signature);
if ($tmpStr == $signature) {
return true;
} else {
return false;
}
}
最佳答案