RSS Feeds
OK, the RSS feeds are up. There is one for the articles, and another for the podcasts. I thought I would fire out this little tidbit that relates to RSS feeds, but is probably a little advanced to ever make it into the magazine.
So an RSS feed is really just an XML file. The process goes that when you subscribe to an RSS feed using an RSS reader (such as Safari or Vienna), it basically bookmarks the URL where it can find the XML file. It will then check that XML file periodically, compare it to the previous version, and notify you of new articles or content. iTunes Podcasting directory works much the same way, only it will also download the mp3 podcast file when it sees that there is a new one available.
OK, so that being said, the RSS feed does not need to be an actual XML file. In our case, the RSS feeds are PHP scripts that then output in the correct XML format. This is something that most tutorials and such about rss seem to leave out. They always seem to imply that you have to manually go in there and update your feed. Not gonna happen with the magazine, so I opted to have the feeds dynamically generated to ensure that fresh content is pulled from the database.
A couple of things. Ouputting the XML format is a piece of cake, and any PHP developer should have no problem. There is the issue of headers. You may try to validate your RSS feed and see an error that the feed and content-type don't match. Content-Type is a header that is sent by the server describing the content. There are two options for RSS feeds:
Content-Type=text/xml- This is the one that you will probably want to use. Since a normal RSS feed is an XML file (a text file), most things expect that this will be the content type.Content-Type=application/rss+xml- this one is a little more specialized. This one denotes that you are trying to send application data. One place to use this is in the head of your HTML documents to allow browsers that are also RSS readers (like Firefox and Safari) to know that there is a feed.
I opted for the previous, since it is more universal and also because the seconde option causes some funny things to happen in Firefox. It would assume that based on the content type I wanted to open an RSS reader application and that was annoying. However, the second one has it's place. Check out the head section of our website to see how we use that content type to display the RSS feed in enabled browsers.
Another thing that will prevent validation is if the character encoding sent by the server does not match the character encoding declared in the RSS feed XML file. For example, in our feed I declare that we are using Unicode (UTF-8) encoding:
So I must also ensure that the ouput of my PHP script is encoded this way as well. Both of the above declarations are handled by the PHP header function. As you can see below, it sets the output content type to "text/xml" and the character encoding to UTF-8:
header(’Content-type: text/xml; charset=UTF-8′);
Hopefully this is helpful to anyone that is interested in creating a dynamic RSS feed, but is having trouble getting it to validate.