基本的に、私は PHP について何も知りませんが、何とかこのスクリプトを機能させることができました。
(このスクリプトは、ライブ ストリームが [www.own3d.tv で] オンラインであるかどうかをチェックし、オンラインの場合はストリーマーの名前と視聴者を表示します。オフラインの場合は何も表示しません。)
Wordpress のサイドバーに挿入しました。しかし問題は、ページを開くと、他のすべてのコンテンツがロードされるのに、サイドバーのロードに数秒かかることです。ライブストリームをチェックするのにとても時間がかかると思います。
では、ロードを高速化する方法や、サイドバーの他のものを最初にロードする方法はありますか?
返信ありがとうございます。
よろしく
<html>
<body>
<p style="width:300px; height:250px; padding:1px; border:5px solid #66a">
<?php
function pageTime()
{
static $_pt;
if($_pt == 0) $_pt = microtime(true);
else return (string)(round(microtime(true)-$_pt ,3));
}
pageTime();
//Froggen
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=112348");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Froggen - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/112348/">Watch now!</a> <br>';
}
else {
echo '';
}
//Athene
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=42146");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Athene - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/42146/">Watch now!</a> <br>';
}
else {
echo '';
}
//Guardsman Bob
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=34046");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Guardsman Bob - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/34046/">Watch now!</a> <br>';
}
else {
echo '';
}
//The Rain Man
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=38853");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'The Rain Man - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/38853/">Watch now!</a> <br>';
}
else {
echo '';
}
//TheOddOne
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=6416");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'TheOddOne - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/6416/">Watch now!</a> <br>';
}
else {
echo '';
}
//Dyrus
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=37905");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Dyrus - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/37905/">Watch now!</a> <br>';
}
else {
echo '';
}
//Xpecial
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=10953");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Xpecial - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/10953/">Watch now!</a> <br>';
}
else {
echo '';
}
//Chaox
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=33356");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Chaox - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/33356/">Watch now!</a> <br>';
}
else {
echo '';
}
//Wickd
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=18755");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Wickd - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/18755/">Watch now!</a> <br>';
}
else {
echo '';
}
//Lapaka
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=214");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Lapaka - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/214/">Watch now!</a> <br>';
}
else {
echo '';
}
//Snoopeh
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=112350");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Snoopeh - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/112350/">Watch now!</a> <br>';
}
else {
echo '';
}
//Dedrayon
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=265558");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Dedrayon - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/265558/">Watch now!</a> <br>';
}
else {
echo '';
}
//Malaco
$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=259259");
$resultlive = $xml->xpath("/own3dReply/liveEvent/isLive");
$resultviewers = $xml->xpath("/own3dReply/liveEvent/liveViewers");
if ($resultlive[0] == 'true'){
echo 'Malaco - Viewers: '; echo ($resultviewers[0]); echo ' - <a href="http://www.own3d.tv/live/259259/">Watch now!</a> <br>';
}
else {
echo '';
}
?>
</p>
</body>
</html>