|
首先感谢@guoma大佬帖子
这个 authorization 是否可以写出代入式 自动获取 请教下
<?php
error_reporting(0);
$id = isset($_GET['id'])?$_GET['id']:'scws';
$n = [
'scws' => 'sctv1',//四川卫视
'scjj' => 'sctv2',//四川经济
'scwhly' => 'sctv3',//四川文化旅游
'scxw' => 'sctv4',//四川新闻
'scyswy' => 'sctv5',//四川影视文艺
'scxkgw' => 'sctv6',//四川星空购物
'scfnet' => 'sctv7',//四川妇女儿童
'scxc' => 'sctv9',//四川乡村
'kbws' => 'kangba',//康巴卫视
];
$t=time();
$url = "https://gw.scgchc.com/app/v1/anti/getLiveSecret?streamName=%2Fhdlive%2F{$n[$id]}8f9fb5888dedbe0c6a1b%2F1.m3u8&txTime=".$t;
$Auth = "@@";//登录四川 电视台https://www.sctv.com/watchTV,获取Authorization
$h = ["Authorization:".$Auth,"Referer: https://www.sctv.com/"];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER,$h);
$data = curl_exec($ch);
curl_close($ch);
$auth = json_decode($data,1)["data"]["secret"];
$playurl = "https://tvshow.scgchc.com/hdlive/{$n[$id]}8f9fb5888dedbe0c6a1b/1.m3u8?".$auth;
header('Content-Type: application/vnd.apple.mpegurl');
header('location:'.$playurl);
echo $playurl;
/*
Authorization获取方法:
1.输入手机号登录;
2.点击浏览器菜单"工具"->"开发者工具",找到"Network";
3.刷新页面;
4.在"开发者工具"左窗口"Name"下找到"https://gw.scgchc.com/app/v1/anti/getLiveSecret?streamName=%2Fhdlive%2Fsctv18f9fb5888dedbe0c6a1b%2F1.m3u8&txTime=xxxxxxxxx";
5.在"开发者工具"右窗口"Headers"下找到"authorization",将其复制粘贴到php代码中@@处。
注:貌视可用一周。
*/
?>
|
|