RSS Validation

Feed 1 posts, 1 voices

Aug 9, 2008 15:30
Avatar
261 posts

I found one more bug in the RSS creation, the lack of time zone. The line:

    <pubDate><?php echo strftime('%a, %d %b %Y %H:%M:%S' -0000); ?></pubDate>
    <lastBuildDate><?php echo strftime('%a, %d %b %Y %H:%M:%S' -0000); ?></lastBuildDate>

Should be:

    <pubDate><?php echo strftime('%a, %d %b %Y %H:%M:%S %Z'); ?></pubDate>
    <lastBuildDate><?php echo strftime('%a, %d %b %Y %H:%M:%S %Z'); ?></lastBuildDate>

And further down, the line:

        <pubDate><?php echo $article->date('%a, %d %b %Y %H:%M:%S' -0000); ?></pubDate>

Should be:

        <pubDate><?php echo $article->date('%a, %d %b %Y %H:%M:%S %Z'); ?></pubDate>

When I change this, the RSS times are shown correctly in Firefox, as opposed to not showing at all.

 
Aug 9, 2008 20:00
Avatar
261 posts

Just a note that this works for Firefox, but not for Google sitemaps. Google sitemaps also requires that you remove the atom link near the top of the rss page.

Delete:

    <atom:link href="<?php echo BASE_URL ?>rss" rel="self" type="application/rss+xml" />

Google wants your times to look like:

    <pubDate><?php echo strftime('%Y-%m-%dT%H:%M:%S-06:00'); ?></pubDate>
    <lastBuildDate><?php echo strftime('%Y-%m-%dT%H:%M:%S-06:00'); ?></lastBuildDate>

Which will look like:

    <pubDate>2008-08-09T17:47:48-06:00</pubDate>

Where -06:00 is the time difference from GMT. I'm sure there's got to be a better way to solve that dynamically. Anyway, I went and created a second RSS feed called bot-rss so that I could also remove the limit of the number of articles that it imports. That way it will pull all of my articles as part of the RSS sitemap.