找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 3106|回复: 24

[iptv信源 资源分享或寻求] 请问下我哪里写错了?

[复制链接]
发表于 2020-11-27 19:05 | 显示全部楼层 |阅读模式
  1. <?php
  2. $url=file_get_contents("https://mediaapi.imbc.com/Player/OnAirURLUtil?type=PC");
  3. preg_match('/"MediaURL":"(.*?)"/i', $url, $m3u8);
  4. print_r($m3u8[1]);
  5. //header('Location:'.$m3u8[1]);
  6. ?>
复制代码


我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2020-11-27 19:06 | 显示全部楼层
打不开,提示:Warning: file_get_contents(https://mediaapi.imbc.com/Player/OnAirURLUtil?type=PC) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-27 19:22 | 显示全部楼层
改用  curl 抓取 试试

点评

不会,怎么弄?  详情 回复 发表于 2020-11-27 19:28
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-11-27 19:28 | 显示全部楼层
heudxk 发表于 2020-11-27 19:22
改用  curl 抓取 试试

不会,怎么弄?

点评

大佬,请教下!  详情 回复 发表于 2020-11-27 20:15
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-27 19:28 | 显示全部楼层
https改为http试试

点评

不行,好像有跨域  详情 回复 发表于 2020-11-27 19:31
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-11-27 19:31 | 显示全部楼层
guoma 发表于 2020-11-27 19:28
https改为http试试

不行,好像有跨域
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-11-27 20:15 | 显示全部楼层

大佬,请教下!

点评

添加一句:header('Access-Control-Allow-Origin:*');试试。  详情 回复 发表于 2020-11-27 21:11
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-27 20:59 | 显示全部楼层
给你吧,极度麻烦的,说不清楚的

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

你的代码不用那么麻烦, UA最重要  详情 回复 发表于 2020-11-27 23:33
大佬牛逼,感谢!  详情 回复 发表于 2020-11-27 21:30
好人一生平安  发表于 2020-11-27 21:27
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-27 21:11 | 显示全部楼层

添加一句:header('Access-Control-Allow-Origin:*');试试。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-11-27 21:30 | 显示全部楼层
kof97zip 发表于 2020-11-27 20:59
给你吧,极度麻烦的,说不清楚的

大佬牛逼,感谢!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-27 23:29 | 显示全部楼层
guoma 发表于 2020-11-27 21:11
添加一句:header('Access-Control-Allow-Origin:*');试试。

<?php
ini_set('user_agent', 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19');//file_get_contents模仿浏览器头(user_agent)获取数据
$url=file_get_contents("https://mediaapi.imbc.com/Player/OnAirURLUtil?type=PC");
preg_match('/"MediaURL":"(.*?)"/i',$url,$m3u8);
//print_r($m3u8[1]);
header('Location:'.$m3u8[1]);
?>
他的代码错误一堆,他,和,就不一样了,两个逗号没转换,还有这个要UA很重要
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-27 23:33 | 显示全部楼层
kof97zip 发表于 2020-11-27 20:59
给你吧,极度麻烦的,说不清楚的

你的代码不用那么麻烦,
<?php
$header = array(

"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2650.0 Iron Safari/537.36",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://mediaapi.imbc.com/Player/OnAirURLUtil?type=PC");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//这句最重要
$result = curl_exec($ch);
curl_close($ch);
$playurl = json_decode($result)->MediaInfo->MediaURL;
header('Location:'.$playurl);
?>
UA最重要

点评

管它呢,不管白猫黑猫,抓到老鼠就是好猫,完全模拟浏览器  详情 回复 发表于 2020-11-27 23:44
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-27 23:44 | 显示全部楼层
shanwoxing 发表于 2020-11-27 23:33
你的代码不用那么麻烦,

UA最重要

管它呢,不管白猫黑猫,抓到老鼠就是好猫,完全模拟浏览器
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-28 00:20 | 显示全部楼层
楼主能看了吗 能分享下吗谢谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-11-28 12:28 | 显示全部楼层
看不了哦 ID是什么

点评

没有ID,直接输出  详情 回复 发表于 2020-11-28 14:37
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-25 19:01

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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

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