This repository has been archived on 2022-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
apiOld/live/bilibili/api.php

50 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2021-01-01 07:48:55 +00:00
<?php
header("Content-type:application/json;charset=utf-8");
function decodeUnicode($str){
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', create_function('$matches', 'return iconv("UCS-2BE","UTF-8",pack("H*", $matches[1]));'), $str);
}
if($_GET['roomid']==null){
2021-02-07 14:28:02 +00:00
header('HTTP/1.1 400 Bad Request');
header('status: 400 Bad Request');
echo '{"error":"400"}';
2021-01-01 07:48:55 +00:00
}else{
$json=@decodeUnicode(@file_get_contents("https://api.live.bilibili.com/xlive/web-room/v1/index/getRoomPlayInfo?room_id=".$_GET['roomid']."&play_url=1&mask=1&qn=0&platform=web"));
if($_GET['mode']=="easy"){
$json=json_decode($json);
echo '{"status":';
foreach($json as $ii=>$ii2){
$$ii = $ii2;
}
foreach($data as $ii=>$ii2){
$$ii = $ii2;
}
echo $live_status.',"roomid":';
echo $room_id.',"uid":';
echo $uid.',"time":';
echo $live_time.',"url1":"';
foreach($play_url as $ii=>$ii2){
$$ii = $ii2;
}
foreach($durl as $ii=>$ii2){
$$ii = $ii2;
}
foreach($durl[0] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url2":"';
foreach($durl[1] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url3":"';
foreach($durl[2] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'","url4":"';
foreach($durl[3] as $ii=>$ii2){
$$ii = $ii2;
}
echo $url.'"}';
}else{
echo $json;
}
}