我的RSS阅读脚本在本地主机上工作正常但在[000webhost]它不起作用,我仔细检查了rss url和脚本,因为任何bug尝试了不同的RSS网址但注意到了作品
它在000webhost生成以下错误
Warning: DOMDocument::load() [domdocument.load]: Document is empty in http://www.voanews.com/api/epiqq, line: 1 in /home/a999999/public_html/index.php on line 190
Warning: DOMDocument::load() [domdocument.load]: Start tag expected, '<' not found in http://www.voanews.com/api/epiqq, line: 1 in /home/a999999/public_html/urdu/index.php on line 190
Fatal error: Call to a member function getElementsByTagName() on a non-object in /home/a999999/public_html/index.php on line 197
我的脚本在
下面$xml=("http://www.voanews.com/api/epiqq");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;
//get and output "<item>" elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<$x->length; $i++) {
$irss[] = array(
'title' => $x->item($i)->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue,
'link' => $x->item($i)->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue,
'description' => $x->item($i)->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue,
'pubDate' => $x->item($i)->getElementsByTagName('pubDate')
->item(0)->childNodes->item(0)->nodeValue
);
}
答案 0 :(得分:0)
您的主机未向外部网址发送请求。出于安全原因,某些主机不允许将某些配置设置永久设置为ON。因此,您必须在需要时启用它。