|
- <?php
- /*
- 常熟新闻综合,xwzh
- 常熟民生经济,msjj
- */
- $id=$_GET['id'];
- $json=dpost("https://api-2019-xmt.21cs.cn/b202002_tv_live_user/Channel_GetChannelList","{}");
- $data=json_decode($json,TRUE);
- if($id=='xwzh'){
- $play_url=$data['list'][0][0]['channel_stream_url'];
- }elseif($id=='msjj'){
- $play_url=$data['list'][0][1]['channel_stream_url'];
- }else{
- exit("ERROR!");
- }
- header("Location: ".$play_url);
- function dpost($url, $post = NULL) {
- $d = parse_url($url);
- $host = str_replace($d['path'],"",$url);
- $headers = array(
- "Content-Type: application/json;charset=UTF-8",
- "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
- "Referer: ".$host,
- "Origin: ".$host,
- "REMOTE_ADDR: ".$ip,
- "X_FORWARDED_FOR: ".$ip
- );
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- if (!empty($post)) {
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
- }
- $re = curl_exec($ch);
- curl_close($ch);
- return $re;
- }
- ?>
复制代码
|
|