我正在爲我的網站上的livestreamers建立一個網頁。Livestream表不會像它應該更新的那樣更新
但是我遇到了一些問題,我創建了一個表格,而且我一直在使用它很多,而且我有很好的結果,但它並不完美,所以我仍然卡住
當前示例http://brokendiamond.org/?q=node/9;
我得到了2個問題; 1我的頁面在大約2 - 3秒內加載,但仍然有點太長 2我的表格中的數據並未像更新一樣更新,當我的數據流啓用後,它不會顯示在我的表格中,即使這個xml文件沒有得到更新,也沒有顯示正確的查看計數,所以有什麼問題,
任何有關這方面的意見,或幫助這個問題將不勝感激,因爲我真的想爲了完成這部分,所以我可以繼續我的待辦事項清單。
我聽說過人們談論兌現,但我不知道如何去做,這可能是一個方向。
的XML API上可以找到: http://api.own3d.tv/liveCheck.php?live_id=210230
和我的網頁的當前的代碼是:
Hello and welcome to the Livestream page for the broken diamond community here you can find all our content creator's livestream pages to watch them game. you can chat with other members and even them! We always welcome new followers and will love to hear about suggestions for games, in game tips and all those opinions we know you have to share! Enjoy your favorite streamers, and don't forget their schedule can be found under the information block in the menu.
<div id="livetable">
</div>
<script type="text/javascript">
load();
var intervalID;
refresh();
function refresh()
{
intervalID = setInterval(load, 60000);
}
function load()
{
var elem = document.getElementById("livetable");
elem.innerHTML = '<?php loadpage() ?><br>';
}
</script>
<?php
define('ELEMENT_CONTENT_ONLY', true);
define('ELEMENT_PRESERVE_TAGS', false);
function value_in($element_name, $xml, $content_only = true)
{
if ($xml == false)
{
return false;
}
$found = preg_match('#<'.$element_name.'(?:\s+[^>]+)?>(.*?)'.'</'.$element_name.'>#s', $xml, $matches);
if ($found != false)
{
if ($content_only)
{
return $matches[1]; //ignore the enclosing tags
}
else
{
return $matches[0]; //return the full pattern match
}
}
// No match found: return false.
return false;
}
function loadpage()
{
echo "<table cellpadding=\"0\" cellspacing=\"0\" style=\"width: 95%\" >";
echo "<tr class=\"info-row\" bgcolor=#252525 style=\"color:white; height: 15px;\">";
echo "<td style=\"width: 14%; height: 10px; padding-left: 5px;\"><b>Preview</b></td>";
echo "<td style=\"width: 10%; height: 10px; padding-left: 5px;\"><b>Live</b></td>";
echo "<td style=\"width: 36%; height: 10px; padding-left: 5px;\"><b>Stream</b></td>";
echo "<td style=\"width: 10%; height: 10px; padding-left: 5px;\"><b>Viewers</b></td>";
echo "<td style=\"width: 10%; height: 10px; padding-left: 5px;\"><b>Time online</b></td>";
echo "</tr>";
addrow(107473,10,"Osuryn","Osuryn is streaming random games live",false);
addrow(210320,28,"Dennojj","Dennojj is streaming PS3 games",true);
echo "</table>";
}
function addrow($streamID, $streamPage , $streamName , $streamSlogan, $odd)
{
if ($odd)
{
echo "<tr class=\"content-row online\" id=\"958\" bgcolor=#A7A7A7>";
}
else
{
echo "<tr class=\"content-row online\" id=\"958\" bgcolor=#BFBFBF>";
}
echo "<td style=\"width: 14%;\"><img src=\"http://img.hw.own3d.tv/live/live_tn_".$streamID."_.jpg\" style=\"height: 72px;\" \></td>";
echo "<td style=\"width: 10%; padding-left: 5px;\"><br><br><b>".getLiveStatus($streamID)."</b></td>";
echo "<td style=\"width: 36%; vertical-align: top; padding-top: 6px; padding-right: 6px;\">";
echo "<div><br><a href=\"http://brokendiamond.org/?q=node/$streamPage\">$streamName</a></div>";
echo "<div style=\"padding-top: 6px; font-size: 11px;\">$streamSlogan</div>";
echo "</td>";
echo "<td style=\"width: 10%; padding-left: 5px;\"><br><br>".getLiveViews($streamID)."</td>";
echo "<td style=\"width: 10%; padding-left: 5px;\"><br><br>".getOnTime($streamID)." minutes online</td>";
echo "</tr>";
}
function getLiveStatus($streamID)
{
$request = 'http://api.own3d.tv/liveCheck.php?live_id='.$streamID;
$arg = '240';
$session = curl_init($request.$arg);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
if (preg_match("/true/",$response, $result))
{
$streamStatus="Live";
}
else
{
$streamStatus="Offline";
}
return $streamStatus;
}
function getLiveViews($StreamID)
{
$request = 'http://api.own3d.tv/liveCheck.php?live_id='.$StreamID;
$arg = '240';
$session = curl_init($request.$arg);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$viewStatus =value_in('liveViewers', $response) + "";
return $viewStatus;
}
function getOnTime($StreamID)
{
$request = 'http://api.own3d.tv/liveCheck.php?live_id='.$StreamID;
$arg = '240';
$session = curl_init($request.$arg);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$onStatus =value_in('LiveDuration', $response) + "";
return $onStatus;
}
?>
秒以內擊敗我! :D – Craig 2012-02-04 03:22:56
其中一個問題是,即使我從頭開始重新加載頁面(CTRL + F5),它也不會顯示任何更改:s – Jonathan 2012-02-04 12:59:31
它們是否完全抑制了它們的API? – 2012-02-04 15:47:23