get(config('openApi.yadi.openTimeKey')); $ttl = config('openApi.yadi.ttl'); $now = Carbon::now()->timestamp; if($now-$tokenTime > $ttl){ return response()->json(['error'=>'token过期,请重新登录'],401); } $username = config('openApi.yadi.username'); $password = config('openApi.yadi.password'); $secret = config('openApi.yadi.secret'); if ($request->header('authorization') == md5($username . $password . $secret)) { return $next($request); } else { return response()->json(['error' => 'token无效,请重新登录'], 401); } } }