SimplePie html rssfeeds Codeigniter

I wanted to ask if I have a div that I would like to post RSS feeds from the BBC or CNN. Now that it works, but I wanted to break the channels entering the system, display 5 at the same time, and the rest are shown when clicking links.

Now I'm starting to write code, but I was hoping to get either inspiration or an example from which to draw.

+3
source share
2 answers

Take a look at the SimplePie RSS and CodeIgniter class , also check the Plugins and integration of SimplePie and SimplePie CodeIgniter Library , learn more and learn it yourself.

0
source

I used the Haughin Simple CodeIgniter Library . It is very easy to use.

$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>";

You can check the code here .

0
source

Source: https://habr.com/ru/post/1721034/


All Articles