Since things were so simple, I thought I'd share how I went about building things to maybe help those that are interested in it.
The first thing I looked up was "What is RSS" in Google. This returned a couple of good articles, mainly the full explanation from everyone's favorite encyclopedia (except China), Wikipedia. RSS stands for "Really Simple Syndication" and is used to port fresh content from a Website to an aggregator. Cool.
Next, I needed to find out the specifications for RSS. This returned a Harvard Law Website, which at first seemed weird but hey, if you can't trust Harvard Law these days, who can you trust?
It turns out that this page would be all that I'd really need.
Not only did this site provided the basic explanation for RSS again, but also gave sample files right off to get a feel for what I was going to build. I love it when tutorials do that, because I'd rather see what I'll be creating, and then have each piece explained to me. In fact, I'm sure you could get everything you want from that page, so I'll just use this as a general overview of steps and the 'gotchas' I came across along the way.
Note, this is geared towards making an RSS feed for your blog, but you can easily incorporate this information into make an RSS feed for anything.
The first thing to decide on is what standard you want to adhere to. I chose 2.0, mainly because it seemed the most recent, and is what all of the cool tech sites (or mainly digg.com) use.
To start your feed, declare your XML intentions and then open an rss tag, and inside of that, start a channel tag:
Before loading items, we have to create a title and description for our RSS feed. This will be used by aggregators to determine where the feed came from and what it's about. We do this by adding some tags not inside an item tag. This is what we used:
Now that we have our channel defined (which again, is just your feed), we need to add items. Each item you add will be one entry displayed in your feed. Simple enough.
Items use a lot of the same tags as channel, and just using the basics are pretty much good enough. Here is a sample item based on the tags that we used:
Also, guid (which stands for globally unique identifier) is used by aggregators to determine if a feed has new entries or not. Think of this as the primary key in MySQL. Further research said that there is no required syntax for this, but from what I find there are a couple of standards that you should try and follow:
- Use Your Website
- Start your guid with your website, that way you never accidentally copy over another feed from another site.
- Use a Link that Links to Your Site/Entry
- Opera seems to use the guid as the link to the item you're talking about instead of the actual link tag. I'm not sure why, but just a heads up.
You can add as many of these item tags as you'd like. When you're done adding items, all you have to is close your channel and rss tags, like so:
It's a good idea to validate your feed once you have it created. I used FeedValidator.org to accomplish this, as they give you a very simple interface with clear error messaging.
I found there were a couple of common errors that kept getting returned. Since our blog is called "Communiqué", the é kept causing problems (in fact not just in the RSS feed, but around the site too, for links and such). You should use HTML entities when creating characters like this, but in this case, I took a different road. To convert our titles into nice search engine friendly ones, we created a PHP function that takes a string of text (which would be your title in most cases), strips out the weird characters, converts spaces to underscores, and converts accented characters to non-accented versions of the same character. While this may seem like a bad practice, we took into account a couple of key thoughts:
- Most people won't confuse a word without accents with a word with the appropriate accents when it's used in context.
- A blog is about communication, and communication is information travelling from one person to another person intact. Without these accents, the message will still get through correctly 99.9% of the time.
- Building off #2, well, you can't please all of the people all of the time.
Finally (yes, finally), the concept of live bookmarking. We all use Mozilla's Firefox around the office here, and with this browser comes the option of live bookmarking. This allows you to subscribe to a feed as a bookmark, and it automatically refreshes throughout the day. (If you're on Firefox, down at the bottom of your screen there should be a small orange icon in the status bar. Click that.) At first I was perplexed as to how to get this to appear, but found the solution. It all happens in your page's head tag:
The title is what will pop up when a user clicks on the orange icon, and it's used to tell which feed they're subscribing too. This is good if you have multiple feeds on one page. The href points to your RSS feed (just like you'd create an HTML link). You can have as many of these tags as you want, and each will list separately in the list of options in which users can subscribe.
And there you have it, an RSS crash course. I went from just knowing of this technology to having a decent handle on it in about ninety minutes, and its application seems greatly useful all over the place (and all thanks to the user comment my last entry received). Hope this helps, and if you have any tips of your own, please add them in a comment below.