Icecast无线电状态不起作用


Icecast radio status does not work

所以我在这个网站上很忙,它需要一个收音机。他们使用的是冰播服务器,所以我从互联网上获取了冰播状态:

    <?php
$icecast_url='http://178.32.13.195:8002';
$output = file_get_contents($icecast_url);
$search='#<div class="newscontent">.*?Point /(.*?)<.*?href="(.*?)">M3U<.*?Listeners.*?class="streamdata">(.*?)<.*?Song:.*?class="streamdata">(.*?)<.*?</div>#si';
preg_match_all($search, $output, $matches);
$j=count($matches[0]);
for ($i=0;$i<$j; $i++) {
    $point_name=$matches[1][$i];
    $pount_m3u=$icecast_url.$matches[2][$i];
    $point_listners_count=$matches[3][$i];
    $point_current_song=$matches[4][$i];
//
    echo 'mount point: <b>'.$point_name.'</b>
';
    echo 'm3u: <a href="'.$pount_m3u.'">'.$pount_m3u.'</a>
';
    echo 'listners_count: <b>'.$point_listners_count.'</b>
';
    echo 'point_current_song: <b>'. $point_current_song.'</b>

';
}
?>

但它不起作用。它只是显示一个空白页。你们中有人知道出了什么问题吗?

感谢

他们使用的是Icecast 2.4.0,它得到了一个重新设计的Admin接口,这破坏了您的解析代码。请不要试图解析html,每当他们更新Icecast和html更改时,它就会中断。相反,您可以尝试新引入的status-json.xsl,即对于该服务器,它位于此处:http://178.32.13.195:8002/status-json.xsl

请注意,不幸的是,由于json-xslt中的一个错误,这不是有效的json。这个问题在Icecast 2.4.1中得到了修复,所以如果你可以访问服务器,你可以很快更新到Icecast 2.4.1。如果你不能访问服务器,你就没有什么可做的了,但解析HTML是最糟糕的方法。