无法使用php获取RSS内容
我正在尝试使用php阅读RSS提要。我开发了这段代码,它在本地XAMPP服务器上运行良好,但当我将其上载到Web服务器时,它无法获取任何内容,也不会生成任何错误无法使用php获取RSS内容,php,rss,Php,Rss,我正在尝试使用php阅读RSS提要。我开发了这段代码,它在本地XAMPP服务器上运行良好,但当我将其上载到Web服务器时,它无法获取任何内容,也不会生成任何错误 <?php try { //Read the RSS content $rss = new DOMDocument(); $rss->load('http://properstatus.com/rss.php'); $feed = array(); foreach ($rss->getE
<?php
try {
//Read the RSS content
$rss = new DOMDocument();
$rss->load('http://properstatus.com/rss.php');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array(
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue
);
array_push($feed, $item);
}
$limit = 6;
$link = "http://bit.ly/1HmbPn4 ";
for ($x = 0; $x < $limit; $x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$description = $feed[$x]['desc'];
$payload = $title . "..." . $link;
echo "Desc: " . $description . "<br/>";
}
} catch (Exception $ex) {
echo $ex->getMessage();
die();
}
?>
你能发现代码中有什么错误吗?或者可能是版本冲突?本地主机运行PHP5.5.15,服务器运行PHP5.5.20
备注:代码已上传,可在不
array\u push($feed,$item)进行现场测试代码>属于它上面的循环。@JimGarrison是的,你是对的,我在格式化代码时似乎犯了这个错误,谢谢你,我会编辑它。虽然@JimGarrison页面仍然加载为空,但没有解决这个问题,我不知道这里可能有什么问题