我已經使用這個PHP來迎接我的博客的最新帖子:使用php獲取wordpress的最新博客文章?
function read_rss($display=0,$url='') {
$doc = new DOMDocument();
$doc->load($url);
$itemArr = array();
foreach ($doc->getElementsByTagName('item') as $node) {
if ($display == 0) {
break;
}
$itemRSS = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'description' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
);
array_push($itemArr, $itemRSS);
$display--;
}
return $itemArr;
}
我得知這一關的教程,因爲我不知道怎麼做這個任務。但是它的工作原理,但我不斷收到這個錯誤在我的錯誤日誌打印:
[12-Jun-2010 06:13:36] PHP Warning: DOMDocument::load() [<a href='domdocument.load'>domdocument.load</a>]: Document is empty in http://www.prettyklicks.com/blog/?feed=rss2, line: 1 in public_html/includes/functions.php on line 153
[12-Jun-2010 06:13:36] PHP Warning: DOMDocument::load() [<a href='domdocument.load'>domdocument.load</a>]: Start tag expected, '<' not found in http://www.prettyklicks.com/blog/?feed=rss2, line: 1 in public_html/includes/functions.php on line 153
任何想法?
謝謝!
什麼是第16行的public_html/portfolio.php和第79行的public_html/includes/functions.php? – 2010-06-19 17:06:02
抱歉,實際上與錯誤沒有任何關係,我編輯了!原始問題 – 2010-06-27 12:52:39