PHP rss阅读器不起作用

时间:2012-06-25 04:57:11

标签: php xml facebook rss

嘿,我写这篇文章是为了获取FB页面提要并将其输出到网站。

从我的localhost可以正常工作,但是当它放在服务器上时却没有。它只是空白。

<?php
$xml_url = "http://fbrss.com/f/7f823b5ba0557decbd324199136326ac_7LpQh7MAJ22MISS1omjI.xml";
$xml = simplexml_load_file($xml_url);

$json = json_encode($xml);
$objects = json_decode($json,TRUE);
$object = $objects;

$i=0;
foreach ($object as $items) {
    $json = json_encode($items);
    $objects = json_decode($json,TRUE);
    $object = $objects;
    $i=0;
    foreach ($object as $items) {
        $item[$i] = $items;
        $i++;
    }

}
$entries = $item[5];
foreach ($entries as $entry) {
    echo '<a href="'.$entry["guid"].'">', substr($entry["title"], 0, 50), '...</a><br /><span>', substr($entry["pubDate"], 4, 18),'</span><br /><hr /><br />';
}   
?>

我的问题是1)为什么它会在现场工作,2)有更好的方法吗?

更新

好的我已经删除了错误日志,这就是我得到的:

[Mon Jun 25 03:08:20 2012] [debug] mod_deflate.c(615):[client 74.192.47.34] Zlib:压缩0到2:URL / * / * /xmlFeed.php(*由我添加)

那么......它是一个压缩问题?它是什么意思,我该怎么办?

1 个答案:

答案 0 :(得分:1)

试试这个,它会起作用。

<?php
$xml_url = "http://fbrss.com/f/7f823b5ba0557decbd324199136326ac_7LpQh7MAJ22MISS1omjI.xml";
$xml = simplexml_load_file($xml_url);

foreach ($xml->channel->item as $item) {
    echo '<a href="'.$item->guid.'">', substr($item->title, 0, 50), '...</a><br /><span>', substr($item->pubDate, 4, 18),'</span><br /><hr /><br />';
}
?>

简短,甜蜜,简单。

相关问题