本帖最后由 tengfei 于 2026-1-28 12:53 编辑
<?php
function getLivePlaylistAppUrl($disableSslVerify = false) {
$channelId = 7;
$sid = "jrsq";
$secretKey = "7190d04B86924128";
$host = "www.jinrishunqing.com";
$url = "https://{$host}/api-w/web/live/playlist";
$itemDate = date("Y/m/d");
$params = [
"channelId" => $channelId,
"itemDate" => $itemDate,
];
$sig = generateSignature($params, $sid, $secretKey);
$params['sid'] = $sid;
$params['sig'] = $sig;
$fullUrl = $url . "?" . http_build_query($params);
$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 Edge/144.0.0.0",
"X-Requested-With: XMLHttpRequest",
];
$ch = curl_init();
$options = [
CURLOPT_URL => $fullUrl,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
];
if ($disableSslVerify) {
$options[CURLOPT_SSL_VERIFYPEER] = 0;
$options[CURLOPT_SSL_VERIFYHOST] = 0;
} else {
$options[CURLOPT_SSL_VERIFYPEER] = 1;
$options[CURLOPT_SSL_VERIFYHOST] = 2;
}
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
$appUrl = null;
if (isset($result['channel']['appUrl']) && json_last_error() === JSON_ERROR_NONE) {
$appUrl = $result['channel']['appUrl'];
}
return $appUrl;
}
function generateSignature($params, $sid, $secretKey) {
ksort($params);
$valueString = implode('', $params);
$signStr = $sid . $valueString . $secretKey;
return md5($signStr);
}
$appUrl = getLivePlaylistAppUrl(true);
if ($appUrl) {
header('Location: ' . $appUrl);
exit;
} else {
echo "没有获取到有效的 appUrl。";
}
?>
|