input('app_id'); $time=$request->input('time'); //时间戳 $nonce=$request->input('nonce'); $sign=$request->input('sign'); $timeDiff = abs(time() - $time); // 获取时间差的绝对值 if ($timeDiff >= 600) { Log::error('签名验证失败-时间异常', [ 'app_id' => $app_id, 'time' => $time, 'current_time' => time(), 'time_diff' => $timeDiff, 'nonce' => $nonce, 'sign' => $sign, 'url' => $request->getPathInfo() ]); return \Yz::echoError1('时间异常'); } $cha_s=DB::table('outside_user')->where(['app_id'=>$app_id])->get(); if(!count($cha_s)==1) { Log::error('签名验证失败-第三方用户不存在', [ 'app_id' => $app_id, 'time' => $time, 'nonce' => $nonce, 'sign' => $sign, 'url' => $request->getPathInfo(), 'user_count' => count($cha_s) ]); return \Yz::echoError1('第三方用户不存在'); } $s_sign=strtoupper(md5($app_id.$time.$nonce.$cha_s[0]->app_secrect)); if($sign<>$s_sign) { Log::error('签名验证失败-签名不匹配', [ 'app_id' => $app_id, 'time' => $time, 'nonce' => $nonce, 'client_sign' => $sign, 'server_sign' => $s_sign, 'url' => $request->getPathInfo() ]); return \Yz::echoError1('签名验证失败'); } return $next($request); } }