500, "msg" => "No videos found", "videos" => null ]; } else { // 随机选择一个视频文件 $randomVideo = $videos[array_rand($videos)]; $videoUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $randomVideo; // 构建响应数组 $response = [ "code" => 200, "msg" => "success", "videos" => $videoUrl ]; } // 将响应数组编码为JSON $jsonResponse = json_encode($response); // 替换JSON字符串中的反斜杠 $jsonResponse = str_replace('\/', '/', $jsonResponse); // 输出JSON响应 echo $jsonResponse; ?>