以下是一个 PHP 示例代码,用于实现上述功能: ```php <?php if(isset($_GET['url'])) { $videoid = $_GET['url']; $newUrl = "https://www.wegame.com.cn/api/forum/lua/wg_video/get_video_play_info?videoid=han_$videoid&upload_type=0&platform=2"; // 使用 cURL 发起请求 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $newUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // 解析 JSON 响应 $data = json_decode($response, true); if(isset($data[0]['url_list'][0])) { $url = $data[0]['url_list'][0]; $parsedUrl = parse_url($url); echo $parsedUrl['scheme']; } } ?> ``` 在上述代码中,首先检查 `GET` 请求中是否存在 `url` 参数。然后构建新的 URL 并使用 `cURL` 发送请求获取响应。最后解析响应中的 JSON 数据,获取 `url_list` 中的第一个 URL,并使用 `parse_url` 函数截取其协议部分(即 `https` )并输出。 [2024-09-09 04:49:45 | AI写代码神器 | 312点数解答]