找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 2270|回复: 67

[iptv信源 资源分享或寻求] PHP获取CBA赛事ID一例1.2版

  [复制链接]
发表于 2022-12-10 18:59 | 显示全部楼层 |阅读模式
本帖最后由 jiteloozz 于 2022-12-15 20:30 编辑

尝试写了一个,仅做测试学习,欢迎指正。。。

  1. <?php
  2. header('Content-Type: text/json;charset=UTF-8');
  3. $url = 'https://v1-sc.miguvideo.com/vms-match/v6/staticcache/basic/match-list/normal-match-list/0/2221401/default/1/miguvideo';
  4. $data = json_decode(get_data($url));   
  5. $nowdays = date('Ymd');
  6. $days =$data->body->days;
  7. $num=array_keys($days,$nowdays)[0];
  8. $prevdays=$days[$num-1];
  9. foreach ($data->body->matchList->$nowdays as $match){
  10.   if($match->matchStatus==1){   //直播
  11.     $pids[]=$match->pID;
  12.   }
  13.   if($match->matchStatus==2){   //回放
  14.     $mids[]=$match->mgdbId;
  15.   }
  16. }
  17. $ids=!empty($pids)?$pids:$mids;
  18. if(!empty($ids)){
  19.   $playtype =in_array($_GET['type'],array_keys($ids),true)?$_GET['type']:array_rand($ids,1);
  20.   $id=$ids[$playtype];  
  21. }else{   //当日若无赛事,则获取前一天的回放ID
  22.   foreach ($data->body->matchList->$prevdays as $match){
  23.     if($match->matchStatus==2){
  24.       $mids[]=$match->mgdbId;
  25.     }
  26.   }
  27.   $id=$mids[array_rand($mids,1)];
  28. }
  29. if(strlen($id)>9){
  30.   $bsurl='https://v1-sc.miguvideo.com/vms-match/v6/staticcache/basic/basic-data/'.$id.'/miguvideo';
  31.   $info = json_decode(get_data($bsurl));
  32.   $id=$info->body->multiPlayList->preList[0]->pID ;
  33.   if($id==null){
  34.     $id=$info->body->pID ;
  35.   }
  36. }
  37. echo $id;
  38. //ID获取完毕,后面部分加入坛里的代码即可,此处省略
  39. function get_data($url){
  40.   $headers = array(
  41.     'Accept-Encoding: gzip, deflate',
  42.     'Referer: https://www.miguvideo.com/mgs/website/prd/sportMatchDetail.html?competitionId=2221401',  
  43.     );
  44.   $ch = curl_init();
  45.   curl_setopt($ch, CURLOPT_URL, $url);
  46.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  47.   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  48.   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  49.   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  50.   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  51.   curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
  52.   $data = curl_exec($ch);
  53.   curl_close($ch);
  54.   return $data;
  55. }
复制代码
12.11 优化第19句代码:
$playtype =in_array($_GET['type'],array_keys($ids),true)?$_GET['type']:array_rand($ids,1);改为:
$playtype =isset($_GET['type'])&&!empty($ids[$_GET['type']])?$_GET['type']:array_rand($ids,1);



我的恩山、我的无线 The best wifi forum is right here.
发表于 2022-12-10 19:04 | 显示全部楼层
学习学习
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:13 | 显示全部楼层

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

使用道具 举报

发表于 2022-12-10 19:16 | 显示全部楼层
谢谢分享,辛苦了!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:18 | 显示全部楼层
学习学习
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:20 | 显示全部楼层
顶楼主啦..希望楼主多发精品好帖啦.....
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:25 来自手机 | 显示全部楼层
感谢大神编写
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:25 | 显示全部楼层
多谢分享。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:34 | 显示全部楼层
感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:41 | 显示全部楼层
感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:44 | 显示全部楼层
学习学习
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:47 | 显示全部楼层
返回是一串数字,放不了

点评

返回的是ID 后面还要加坛里guoma大佬的代码。。。  详情 回复 发表于 2022-12-10 19:51
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:48 | 显示全部楼层
谢谢分享,辛苦了!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-12-10 19:51 来自手机 | 显示全部楼层
大神就是牛人
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-12-10 19:51 | 显示全部楼层
jie333 发表于 2022-12-10 19:47
返回是一串数字,放不了

返回的是ID

后面还要加坛里guoma大佬的代码。。。

点评

加的是什么说一下。  发表于 2022-12-11 08:45
怎么加呢  详情 回复 发表于 2022-12-10 20:30
哦,谢谢  详情 回复 发表于 2022-12-10 19:53
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-29 22:28

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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

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