zjcheng 发表于 2024-6-12 04:40:22

贵州习水电视台

习水电视台源码<?php
// 获取 id 参数,如果未设置则默认为 'xszh'
$id = isset($_GET['id']) ? $_GET['id'] : 'xszh';
$n = [
    'xsjj' => 'https://ali-live.xishuirm.cn/live/app3.m3u8', // 习水经济
    'xszh' => 'https://ali-live.xishuirm.cn/live/app2.m3u8', // 习水综合
];
$url = isset($n[$id]) ? $n[$id] : $n['xszh'];
$auth_url = "http://nn.7x9d.cn/地方台/小曾.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $auth_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$auth_response = curl_exec($ch);
curl_close($ch);
$Authorization = trim($auth_response);
if (empty($Authorization)) {
    die("Error: Unable to fetch Authorization token.");
}
$api_url = "http://api-cms.xishuirm.cn/v1/mobile/channel/play_auth/?stream=" . urlencode($url);
$headers = [
    "Authorization: $Authorization",
    'Host: api-cms.xishuirm.cn',
    'Connection: Keep-Alive',
    'Accept-Encoding: gzip',
    'User-Agent: okhttp/3.11.0'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status_code == 200) {
    if (substr($response, 0, 2) === "\x1f\x8b") {
      $response = gzinflate(substr($response, 10, -8));
    }
    $decoded_response = json_decode($response, true);
    if (isset($decoded_response['data']['auth_key'])) {
      $auth_key = $decoded_response['data']['auth_key'];
      $stream_url = "$url?auth_key=$auth_key";
      header("Location: $stream_url");
      exit;
    } else {
      die("Error: Authorization key not found in the response.");
    }
} else {
    die("Error: Failed to get authorization with status code $status_code.");
}
?>

chenfeilf 发表于 2024-6-12 07:11:24

感谢分享

JXD1987 发表于 2024-6-12 07:22:05

习水电视台源码

四维 发表于 2024-6-12 09:00:20

十分感谢

H5N1 发表于 2024-6-12 11:20:11

http://nn.7x9d.cn/地方台/小曾.php{:4_95:}

495579522 发表于 2024-6-13 23:00:42

这个怎么用?求解
页: [1]
查看完整版本: 贵州习水电视台