【问题标题】:SimplePie html rssfeeds CodeigniterSimplePie html rssfeeds Codeigniter
【发布时间】:2010-12-09 23:53:41
【问题描述】:

我想问一下,我有一个 div,我想放置来自 BBC 或 CNN 的 RSS 提要。现在可以了,但我想对进来的提要进行分页,一次显示 5 个,其他的显示链接被点击的时间。

我现在开始编写代码,但我希望我能得到灵感或有一个我可以从中收集到的例子。

【问题讨论】:

    标签: codeigniter simplepie codeigniter-pagination


    【解决方案1】:

    我用过Haughin's Simple CodeIgniter Library。使用起来非常简单。

    $this->load->library('simplepie');
    $this->simplepie->set_feed_url('http://feeds.haughin.com/haughin');
    $this->simplepie->set_cache_location(APPPATH.'cache/rss');
    $this->simplepie->init();
    $this->simplepie->handle_content_type();
    
    $data['rss_items'] = $this->simplepie->get_items();
    
    echo "<li>";
    foreach($rss_items as $item) {
        echo "<li>";
        echo "<a href='" .$item->get_link() . "'>";
        echo $item->get_title();
        echo "</a>";
        echo "</li>";
    }
    echo "</li>";
    

    您可以查看代码here

    【讨论】:

    • 有谁知道如何获取 $item->get_title() 的值并将其添加到变量中?听起来很简单,但我得到的只是:“致命错误:无法在第 162 行的 /home/seedetai/public_html/testseedetail/application/models/post_model.php 中使用 SimplePie_Item 类型的对象作为数组”。
    【解决方案2】:
    猜你喜欢
    • 2011-02-28
    • 2010-12-16
    • 1970-01-01
    • 2013-09-06
    • 2011-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-19
    相关资源
    最近更新 更多