Welcome Guest, Not a member yet? Register   Sign In
Parse RSS feed
#1

[eluser]Hitankar[/eluser]
Is there is a plugin or way to parse RSS fields and convert to something like an array, which I like to save it onto the database.

Thanks.
#2

[eluser]Flemming[/eluser]
SimplePIE worked for me!

http://ellislab.com/forums/viewthread/133938/

http://simplepie.org/

let me know if you need example implementation code
#3

[eluser]pistolPete[/eluser]
Use the forum search and have a look at the wiki:

- http://codeigniter.com/wiki/RSSParser/
- http://codeigniter.com/wiki/RSSParser-PhilMod/
- http://ellislab.com/forums/viewreply/493333/
#4

[eluser]Hitankar[/eluser]
[quote author="Flemming" date="1262709430"]SimplePIE worked for me!

http://ellislab.com/forums/viewthread/133938/

http://simplepie.org/

let me know if you need example implementation code[/quote]

That would be great if I can have an example implementation code. I will get to understand better.

Thanks...
#5

[eluser]Flemming[/eluser]
sorry for the delay - couldn't get to the PC due to snow!

ok - here's some example code for you ... find the simplepie.php library file to your application > libraries folder (you may have to search the forums for it) and then ...

controller:
Code:
function __construct()
{
    parent::Controller();
        $this->load->library('simplepie');
}

function news_feed()
    {
        $this->simplepie->set_feed_url('http://some-url/rss.html');
        $this->simplepie->set_cache_location(APPPATH.'cache/rss');
        $this->simplepie->init();
        $this->simplepie->handle_content_type();
        $data['rss_items'] = $this->simplepie->get_items();            
        $this->load->view('news_feed_view',$data);
    }

and view:
Code:
foreach($rss_items as $item)
{
   echo '<h2>' . $item->title . '</h2>';
   echo '<p>' . $item->text . '</p>';
   echo '<p>' . $item->date . '</p>';
}

hope that gets you on your way?

or you can look here: http://www.haughin.com/code/simplepie/ for the original example! sorry, should have pointed you to that earlier!
#6

[eluser]Hitankar[/eluser]
Thanks a lot. Is there's a way I could save into database, and update the database whenever the feed is updated.
#7

[eluser]Flemming[/eluser]
I suppose you could move this into the controller:

Code:
foreach($rss_items as $item)
{
  // insert into db here using $item->title etc
}
#8

[eluser]angeal99[/eluser]
can anybody give me example site that integrating simplepie with codeligniter??? please....
#9

[eluser]Flemming[/eluser]
what do you need an example of?




Theme © iAndrew 2016 - Forum software by © MyBB