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
2021-02-07 22:28:02 +08:00

50 lines
1.2 KiB
PHP

<?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){
header('HTTP/1.1 400 Bad Request');
header('status: 400 Bad Request');
echo '{"error":"400"}';
}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;
}
}