|
|
- <?php
- function sendGetDetailRequest() {
- $url = "https://rmt-api.dachuan.org.cn/wap/getDetail?vno=3.5.0&";
-
- $headers = [
- "Accept: application/json, text/javascript, */*; q=0.01",
- "Accept-Encoding: gzip, deflate, br, zstd",
- "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
- "Connection: keep-alive",
- "Content-Type: application/x-www-form-urlencoded; charset=UTF-8",
- "Host: rmt-api.dachuan.org.cn",
- "Origin: https://rmt-wap.dachuan.org.cn",
- "Referer: https://rmt-wap.dachuan.org.cn/",
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0",
- "tenantId: 15"
- ];
-
- $formData = [
- "data" => '{"news_id":"30981","sign":""}'
- ];
- $postData = http_build_query($formData);
-
- $ch = curl_init();
- curl_setopt_array($ch, [
- CURLOPT_URL => $url,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $postData,
- CURLOPT_HTTPHEADER => $headers,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_SSL_VERIFYPEER => true,
- CURLOPT_SSL_VERIFYHOST => 2,
- CURLOPT_ENCODING => "",
- ]);
-
- $response = curl_exec($ch);
- $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
- if (curl_errno($ch)) {
- echo "cURL执行错误:" . curl_error($ch);
- curl_close($ch);
- return;
- }
- curl_close($ch);
-
- $responseUtf8 = mb_convert_encoding($response, "UTF-8", mb_detect_encoding($response));
-
- // 解析JSON并提取video_url
- $result = json_decode($responseUtf8, true);
- if (json_last_error() === JSON_ERROR_NONE) {
- // 检查data和video_url是否存在
- if (isset($result['data']['video_url'])) {
- $videoUrl = $result['data']['video_url'];
- header('Location: ' . $videoUrl);
- exit;
- // echo "提取到的video_url:" . $videoUrl;
- } else {
- echo "响应中未找到video_url字段";
- }
- } else {
- echo "JSON解析失败,原始响应:" . $responseUtf8;
- }
- }
- sendGetDetailRequest();
- ?>
复制代码
|
|