无法使用php获取RSS内容

时间:2015-02-15 08:23:56

标签: php rss

我正在尝试使用php阅读RSS源。我开发了这个在本地XAMPP服务器上运行良好的代码但是当我将它上传到我的网络服务器时,它无法获取任何内容并且也不会产生任何错误。

<?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(' & ', ' &amp; ', $feed[$x]['title']);
        $description = $feed[$x]['desc'];
        $payload = $title . "..." . $link;
        echo "Desc: " . $description . "<br/>";        
    }
} catch (Exception $ex) {
    echo $ex->getMessage();
    die();
}
?>

你能发现代码中有什么问题吗?或者它可能是版本冲突? localhost运行php 5.5.15服务器运行php 5.5.20

P.S:代码已上传,可在http://tweet.unistarcrm.com/test.php

进行实时测试

0 个答案:

没有答案