-1
我知道我的代碼很混亂,我對此非常陌生,並且隨時隨地學習。PHP XML失敗
我的網站是這樣的:(目前正在運行我的家用計算機,並使用tvdb api,所以它有點慢)。
大部分似乎工作,目前唯一沒有的是NCIS如下所示:http://itsalllegit.com/season.php?sid=72108&season=1。
我知道它的糟糕和長久,但這裏是我的代碼...我堅持這一個,並將不勝感激(如果有任何提示,使它在一般情況下更好)。
btw ...如果我echo $url3
它提出了"(*#YR&(^#R(@$#%$&^@#%$*@#%$&^@$#&"
等等。
<html>
<head>
<title>Saars - Homepage</title>
<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body>
<?php
$series_id = $_GET["sid"];
$season_number = $_GET["season"];
$local_path = "images/Banner/".$series_id."-Banner.jpg";
$url1 = file_get_contents("http://thetvdb.com/api/E676DF9578EF38D7/series/".urlencode($series_id));
$xml = simplexml_load_string($url1);
$series_name = $xml->Series[0]->SeriesName;
$series_rating = $xml->Series[0]->Rating;
$series_network = $xml->Series[0]->Network;
$series_status = $xml->Series[0]->Status;
echo '<img src="'.$local_path.'"><br />';
echo "Name: ".$series_name."<br />";
echo "Rating: ".$series_rating."<br />";
echo "Network: ".$series_network."<br />";
echo "Status: ".$series_status."<br />";
echo "<hr />";
echo '<table bgcolor="#000000">';
echo '<tr>';
echo '<td width="30">';
echo '<font color="white">#</font>';
echo '</td>';
echo '<td width="500">';
echo '<font color="white">Episode Name</font>';
echo "</td>\n";
echo '<td width="100">';
echo '<font color="white">First Aired</font>';
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
for ($episode_number = 1; $episode_number <= 200; $episode_number++) {
$url2 = "http://thetvdb.com/api/E676DF9578EF38D7/series/".$series_id."/default/".urlencode($season_number)."/".urlencode($episode_number)."/en.xml";
$handle = @fopen($url2, 'r');
if ($handle === false) {
return;
} else {
$url3 = file_get_contents("http://thetvdb.com/api/E676DF9578EF38D7/series/".$series_id."/default/".urlencode($season_number)."/".urlencode($episode_number)."/en.xml");
$xml = simplexml_load_string($url3);
$episode_name = $xml->Episode[0]->EpisodeName;
$episode_rating = $xml->Episode[0]->Rating;
$episode_firstaired = $xml->Episode[0]->FirstAired;
$episode_overview = $xml->Episode[0]->Overview;
$column1 = '<a href="episode.php?sid='.$series_id.'&season='.$season_number.'&episode='.$episode_number.'">'.$episode_number.'</a>';
$column2 = '<a href="episode.php?sid='.$series_id.'&season='.$season_number.'&episode='.$episode_number.'">'.$episode_name.'</a>';
$column3 = '<a href="episode.php?sid='.$series_id.'&season='.$season_number.'&episode='.$episode_number.'">'.$episode_firstaired.'</a>';
echo '<table>';
echo "<tr>\n";
echo '<td width="30">';
echo $column1;
echo "</td>\n";
echo '<td width="500">';
echo $column2;
echo "</td>\n";
echo '<td width="100">';
echo $column3;
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
fclose($handle);
}
}
?>
</Body>
</html>
謝謝,會做,但我不認爲它會幫助很大,因爲到目前爲止它似乎只是NCIS多數民盟這是失敗 – Saars 2012-04-12 12:00:40
我知道這似乎很奇怪,但是當我加載的URL應該與您的代碼生成第一個在我加載頁面時不起作用的是ep 3:http://thetvdb.com/api/E676DF9578EF38D7/series/72108/default/1/3/en.xml)。 – DaveRandom 2012-04-12 12:10:43
我知道......有時候是作品,有時候不是。我想我可能會把一個if語句放在下載它的地方,如果這個語句不是已經在本地的話 – Saars 2012-04-12 12:53:37