Connecting businesses to people through effective online marketing strategy
In: Tutorials
23 Jul 2009MagpieRSS is a PHP based RSS parser that can be downloaded here http://magpierss.sourceforge.net/
What good is it you ask? You can use it to pull in information from any RSS feed and do what ever you want with the data. For example I use it to pull the RSS feed from my blog and display links to my latest posts on http://www.rewardchamp.com You can see it on the bottom of the page.
CakePHP makes this way to easy! First you need to download the MagpieRSS files from the link above and then extract to your vendors folder.
You need to put this line at the very top of your controller file you want to use RSS with. Before the class declaration
App::import('Vendor','Snoopy', array("file" => "magpierss/extlib/Snoopy.class.inc"));
Now inside a function you want create a new Snoopy object. I use Snoopy because I’m lazy … MagpieRSS is not constructed as Classes like CakePHP would like it to be … Snoopy is. Snoopy will return XML for you which you can make into an easily usable object with SimpleXMLElement. You can var_dump to see what exactly is in this object. You can figure out what to do from there.
$snoopy = new Snoopy(); $snoopy->fetch('http://www.solitechgmbh.com/your/feed/here'); $xml = new SimpleXMLElement($snoopy->results); return $xml->channel->item;
Something like this will get you the title for example.
echo $item->title;
Happy coding!
Services such as Facebook, MySpace, LinkedIn, Twitter etc. are experiencing exponential growth. Your company needs to stay competitive and utilize this new technology. We will help you devise and execute a higly effective marketing strategy that will grow your brands' following and deliver measurable results.
Click here to see all our service.
1 Response to How to use MagpieRSS with CakePHP
Korbi Brav
July 25th, 2009 at 9:07 am
Thanks, works great.