找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 3191|回复: 9

[iptv信源 资源分享或寻求] (更新)小白关于TVB php的探讨

[复制链接]
本帖最后由 574946793 于 2021-11-30 11:18 编辑

根据jiteloozz大神的指导,改了一些地方,可以用了,现将更改过的代码发一下:
(第一个)
  1. <font size="2"><?php
  2.         // by wjxgzz @ 2020.06.05 //
  3.         error_reporting(0);
  4.         $id = $_GET['id']; // 新闻网ID=1 财经=2 不知道什么鬼频道=3
  5.         $aryID = array('','51ececd4a4b9a44d3286036c','5a699f3668c55cc22098da62','4f75643af63e5ddc1a000000');
  6.         $bstrURL = 'https://api.news.tvb.com/news/v2.2.1/live?id='.$aryID[$id].'&profile=web';
  7.         // https://api.news.tvb.com/news/v2.2.1/live?profile=web 使用这个接口可以获取全部频道数据.
  8.         $ch = curl_init();
  9.         curl_setopt($ch, CURLOPT_URL, $bstrURL);                  
  10.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  11.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  12.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  13.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; )AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36" );
  14.         $data = curl_exec($ch);
  15.         curl_close($ch);
  16.         $obj = json_decode($data);
  17.         $token_url = $obj->items[0]->video->ios[1]->url;  // 鬼畜网络不OK的时候这里获取不到数据,为空时直接写死token链接
  18.         if ($token_url == '')
  19.         {
  20.         switch($id)
  21.         {
  22.         case 1:
  23.         $token_url = 'http://token.tvb.com/stream/live/hls/mobilehd_news_windows1.smil?app=news';
  24.         break;
  25.         case 2:
  26.         $token_url = 'http://token.tvb.com/stream/live/hls/mobilehd_finance.smil?app=news';
  27.         break;
  28.         case 3:
  29.         $token_url = 'http://token.tvb.com/stream/live/hls/mobilehd_newsevent1.smil?app=news';
  30.         break;
  31.         }

  32.         }
  33.         $bstrURL = 'https://news.tvb.com/ajax_call/getVideo.php?token='.urlencode($token_url.'&feed&client_ip=0.0.0.0');
  34.         $ch = curl_init();
  35.         curl_setopt($ch, CURLOPT_URL, $bstrURL);
  36.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  37.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  38.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  39.         curl_setopt($ch, CURLOPT_COOKIE,"country_code=16bbe2696a70d9b5dd68f39ba676911b;tag_deviceid=00000000000000000000000000;");
  40.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36(KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36" );
  41.         $data = curl_exec($ch);
  42.         curl_close($ch);
  43.         $obj = json_decode($data);
  44.         header('location:'.$obj->url);
  45. ?></font>
复制代码
第二个
<?php
        $id = $_GET['id']; // ID 新闻=1 财*=2 事件直播=3
        $smils = array('','mobilehd_news_windows1','mobilehd_finance','mobilehd_newsevent1');
        $token_url = 'http://token.tvb.com/stream/live/hls/'.$smils[$id].'.smil?app=news';
        $bstrURL = 'https://news.tvb.com/ajax_call/getVideo.php?token='.urlencode($token_url.'&feed&client_ip=0.0.0.0');
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $bstrURL);                  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_COOKIE,"country_code=16bbe2696a70d9b5dd68f39ba676911b;tag_deviceid=00000000000000000000000000;");
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36" );
        $data = curl_exec($ch);
        curl_close($ch);
        $obj = json_decode($data);
        header('location:'.$obj->url);
?>





虽然只有两个台,且播放并不流畅,但是对于我们这种小白,可以学习一下,希望论坛的大神们不要笑话和不吝赐教~~
我的恩山、我的无线 The best wifi forum is right here.
完全不懂,怎么用呢?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

第一个代码要改几处地方:1.地址中去掉所有无关<font color="#ff0000"></font>html语句
2.$token_url = $obj->items[0]->video->ios[1];引用地址变了。改成$token_url = $obj->items[0]->video->ios[1]->url;
3.$bstrURL = 'https://news.tvb.com/ajax_call/getVideo.php?token='.urlencode($token_url.'&feed&client_ip=');此处IP不为空,任意构造一个。
4.加入cookie验证curl语句curl_setopt($ch, CURLOPT_COOKIE,"country_code=16bbe2696a70d9b5dd68f39ba676911b;tag_deviceid=00000000000000000000000000;");

第一段代码多了一个接口地址的获取。

点评

感谢感谢,昨天改了一天都不行,果然还是需要专业的人才行,那个html我是在代码中标红色,没想到发出来就变成颜色的代码了  详情 回复 发表于 2021-11-30 10:56
高手  发表于 2021-11-29 18:56
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

搞来搞去,都是只看两个频道!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
jiteloozz 发表于 2021-11-29 18:34
第一个代码要改几处地方:1.地址中去掉所有无关html语句
2.$token_url = $obj->items[0]->video->ios[1]; ...

感谢感谢,昨天改了一天都不行,果然还是需要专业的人才行,那个<font color="#ff0000"></font>html我是在代码中标红色,没想到发出来就变成颜色的代码了

点评

能看吗?WAMPSERVER  发表于 2021-11-30 18:59
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

好像已经凉了,看不了了。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

朋友我也想学习下怎么写,请问你是从哪里获得学习资料呢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-27 00:58

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表