上海电视节目PHP代理脚本

今天捡了个脚本,节目不多,但是比较稳定,至于能看多久?肯定是看到失效为止。

数据来源于以下接口:

https://bp-api.bestv.cn/cms/api/live/channels

需要用POST方式获取数据,需POST的数据:

Header:Content-Type: application/json

Body:content :{}

如下测试:

接口测试
接口测试

响应数据:

响应数据
响应数据

响应数据中包含了idchannelNamechannelUrl,因此直接可以写个PHP代理发送POST请求,提取响应数据的channelUrl并重定向即可。

完整脚本代码:

<?php
error_reporting(0);
$id = $_GET['id'];
$n = [
    'dfws' => '2030'//上海东方卫视
    'xwzh' => '20'//上海新闻综合
    'xjs' => '1600'//上海新纪实
    'mdy' => '1601'//上海魔都眼
    'lypd' => '1745'//上海乐游频道
    'dycj' => '21'//上海第一财经
    'dspd' => '18'//上海都市频道
    'wxty' => '1605'//上海五星体育
];
$apiurl = 'https://bp-api.bestv.cn/cms/api/live/channels';

$context = stream_context_create([
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
    ],
    'http' => [
        'method' => 'POST',
        'header' => "Content-Type: application/json\r\n",
        'content' => '{}'
    ]
]);

$response = file_get_contents($apiurl, false, $context);
//echo $response;
$data = json_decode($response);

foreach ($data->dt as $channel) {
    if ($channel->id == $n[$id]) {
        $playurl = $channel->channelUrl;
        break;
    }
}

header('Location: ' . $playurl);
?>

来源于:SUV大佬

使用方法

将以上代码保存为xxx.php,上传到PHP主机,然后用你的主机/xxx.php?id= 即可播放对应的节目。

节目列表:

上海东方卫视,http://你的主机地址/xxx.php?id=dfws
上海新闻综合,http://你的主机地址/xxx.php?id=xwzh
上海新纪实,http://你的主机地址/xxx.php?id=xjs
上海魔都眼,http://你的主机地址/xxx.php?id=mdy
上海乐游频道,http://你的主机地址/xxx.php?id=lypd
上海第一财经,http://你的主机地址/xxx.php?id=dycj
上海都市频道,http://你的主机地址/xxx.php?id=dspd
上海五星体育,http://你的主机地址/xxx.php?id=wxty

脚本下载

如果复制脚本运行异常,可以下载原始脚本,私信回复【251101】下载即可

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

滚动至顶部