In my last post, I discussed how to parse an RSS feed with PHP, and display the contents directly on your site.
The advantages of using a server-side programming language to parse an RSS feed are:
- The content is obtained as the page is being served, meaning there is no additional delay for end-viewers.
- You can format the content to fit into your existing HTML markup.
- Sloppy-looking, blocky, hard to customize, and often break site layouts.
- Pull content after the page has loaded, meaning there is an additional “wait time” as the client browser reaches out to the remote URL’s.
RSS as an API
In a sense, an RSS feed is an API. On systems where you don’t have direct access to the server or database, using the public RSS feed is the only way to obtain the content for use elsewhere.
The main drawback to using an RSS feed as an API is you are limited to whatever is in the RSS feed, meaning if the feed only displays 10 posts, you can only obtain 10 posts. Most RSS feeds have a limit of how many items are displayed. This site has over 1,000 blog posts. However, my RSS feed only displays the 10 most recent.
It would serve me no purpose to offer a feed that contains every post. I can imagine it would only cause the file to be extremely large, slowing down feed readers’ response time when trying to access my feed for subscribers.
However, offering a “flag” on the feed itself could be useful. In other words, here’s the RSS feed for this site:
This pulls the 10 most recent posts. What if a user wanted to write an application using my data, but needed access to every post? I could provide a “flag” or “parameter” for them to supply:
The variable count could be set to any number, or “all” for all posts.
It might be wise to consider authenticating the “all” feed, and providing access to individuals as you see fit.