Need Ideas to Blog About?
Get better search placement fast
1 comment »Integrating external feeds: Part 1A wise man one said "You have been given two hands. One to give and the other to receive." In the spirit of that quote we are going to write a multiple part article on itegrating remote RSS feeds into your existing website. The examples in this series are meant to be a guide for integrating feeds and not necessarily an exhaustive imlementation so standard *disclaimers apply. That having been said, let's begin.
The ToolsIn this first article we will show you how to implement a basic RSS feed using SimplePie. We have chosen SimplePie because its implementation of feed reading is reasonably complete with support for RSS and Atom as well as enclosures for the podcast inclined. SimplePie requires PHP 4.3+ or PHP 5.0.3+ which is a pretty common configuration for most servers and hosting environments. It also needs the XML extension and curl or an unlocked fopen. If you have these, you may now pass Go and download the scripts so we can begin. In addition to SimplePie's ability to read feeds, it is also responsible for the caching of feeds and this is a tremendous value. Some feed reading examples use Javascript and by virtue of its use the feeds that are displayed suffer common maladies like no or poor caching resulting in slow page loads for visitors and no SEO value for the actual feed. While these are important topics, they are not appropriate for this article and have been addressed in other posts. Because the code is so brief in this example, we will merely address the key points which inclusion of SimplePie and creating the objects that read the feeds. Rather than reference the scripts through relative paths, this script expects and requires that SimplePie is installed in a subdirectory below the example script and named 'SimplePie' SimplePie uses classes to encapsulate the feed reading behavior so elementary understanding of objects and OOP would be helpful but these next tidbits will example what is happening.
The million mile viewThe following line of code creates a new SimplePie object and is resposible for doing the basic housekeeping that makes feed reading possible.
This line tells the feed reading object which URL we will be processing. The URL was passed into the feed reader function and for the sake of this example is pointing at our own RSS feed.
This line causes SimplePie to read the feed and store the RSS items for later access. At this point SimplePie has decided if the cache is present and/or expired and chooses to either read the feed from the website or simply pull a copy from its cache. SimplePie allows you to set the cache lifetime but we have opted for the defaults to keep this example simple.
The next lines of code in the full listing below merely walk the items that were pulled and displays them. We have used basic tags for display so the output can be customized through CSS. This next block represents the functional example which forms the basis example.
I'll leave you with this code to test, digest and play with for now. In part two we will implement the options parameter and roll the code into a WordPress plugin so you can see it in action. *While we strive to write complete and functional examples it is possible that a bug or two slips through the cracks. Where possible and known they will be addressed but this should certainly get you started. Related PostsTRAFFIC DRIVING contentGenerate 100+ More Quality Real Estate Leads per Month by Feeding Your Blog RSS Feeds from the MLS Are RSS feeds killing your website? Why Realtors Should Use RSS Why you must have a blog by January 07 Posted in RSS Marketing Comment from: Posicionamiento valencia [Visitor] A good article about simple pie rss reader. Comment on this article This post has no comments awaiting moderation. |



Like what you are reading here? Then let us email you with all our new content.





Free eBook
Get More Leads
Posted in