本帖最后由 ybs110 于 2026-1-28 12:35 编辑
<?php
/**
* 极简版:请求接口并提取 appUrl(无任何打印输出)
*/
function getLivePlaylistAppUrl() {
// 1. 配置固定参数
$channelId = 7;
$sid = "jrsq";
$sigSuffix = "7190d04B86924128";
$host = "www.jinrishunqing.com";
$url = "https://{$host}/api-w/web/live/playlist";
// 2. 获取当天日期并格式化
$itemDate = date("Y/m/d");
// 3. 生成 sig
$sigRaw = "{$sid}{$channelId}{$itemDate}{$sigSuffix}";
$sig = md5($sigRaw);
// 4. 构建完整请求URL
$params = [
"channelId" => $channelId,
"itemDate" => $itemDate,
"sid" => $sid,
"sig" => $sig
];
$fullUrl = $url . "?" . http_build_query($params);
// 5. 配置请求头
$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",
"Host: {$host}",
"Referer: https://{$host}/live/liveDetail.html?channelId={$channelId}&articleID=10747652",
"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",
"X-Requested-With: XMLHttpRequest",
];
// 6. 发送 cURL 请求
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $fullUrl,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER =>0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_ENCODING => "",
]);
$response = curl_exec($ch);
curl_close($ch);
// 7. 解析并提取 appUrl(带容错,无打印)
$result = json_decode($response, true);
$appUrl = null;
if (isset($result['channel']) && isset($result['channel']['appUrl']) && json_last_error() === JSON_ERROR_NONE) {
$appUrl = $result['channel']['appUrl'];
}
// 8. 直接返回 appUrl(核心结果)
return $appUrl;
}
// 调用函数获取 appUrl(如需使用,直接赋值即可)
$appUrl = getLivePlaylistAppUrl();
// echo $appUrl;
header('Location: ' . $appUrl);
exit;
?>
|