|
用这个试试
- <?php
- $id = isset($_GET['id'])?$_GET['id']:'fcgxwzh';
- $type = isset($_GET['type'])?$_GET['type']:'hls';
- $ref='http://www.fcgtvb.com/lives/';
- $n = array(
- 'fcgxwzh' => 'app1',
- 'fcggg' => 'app3',
- );
- $d = json_decode(file_get_contents('https://api-cms.fcgtvb.com/v1/mobile/channel/play_auth?stream=https%3A%2F%2Flive.fcgtvb.com%2Flive%2F'.$n[$id].'.m3u8'));
- $auth_key = $d->data->auth_key;
- $playurl = 'https://live.fcgtvb.com/live/'.$n[$id].'.m3u8?auth_key='.$auth_key;
- if($type == 'hls'){
- $data = m3u8($playurl,$ref);
- $ts = str_replace('live','fcg.php?type=ts&url=https://live.fcgtvb.com/live/&ts=live',$data);
- print_r($ts);
- }else if($type=='ts'){
- $url = $_GET['url'];
- $ts = $_GET['ts'];
- ts($url.$ts,$ref);
- }
- function m3u8($playurl,$r){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $playurl);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_REFERER, $r);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- function ts($playurl,$r){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $playurl);
- curl_setopt($ch, CURLOPT_REFERER, $r);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- $data = curl_exec($ch);
- curl_close($ch);
- }
- ?>
复制代码 |
|