PHP在运行时不读取RSS,但在本地服务器上读取良好


PHP not reading RSS when live, but reads fine at local Server

我的RSS阅读脚本在本地主机上工作良好,但在[000webhost]它不工作,我仔细检查了RSS url和脚本的任何错误尝试不同的RSS url,但注意工作

在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
  );
} 

您的主机没有向外部URL发送请求。出于安全原因,有些主机不允许将某些配置设置永久设置为ON。因此,您必须在需要时启用它。