Weird Looking: broken gmail feeds

broken gmail feeds

September 4, 2006 1:53pm (4 years, 2 days and 20 hours ago)
Gmail provides Atom feeds of your inbox, but they come at a price.  And the price is the possibility of having to deal with them.  Mine kept causing an error in RSS Bandit.  At first I tried to blame the aggregator, but then I took a closer look at the feed itself…

<entry>
 ...
 <modified>2006-09-03T24:56:06Z</modified>
 <issued>2006-09-03T24:56:06Z</issued>
 ...
</entry>


That email was received at nearly 25 o’clock, eh?  The interesting part is, it came in at 1am on the third (GMT).    So not only is it an invalid date, it’s off by 24 hours.  I guess they just forgot to mod the hour by 24 or something.

I submitted a bug to Google, and they promptly replied with an automated message!  It seems they aren’t able to respond directly to my report, but they are working on these issues.  I know I feel better about it ever getting fixed.

So what I did was, I built myself a little proxy script that fixes the time.  I still need to make it pass through the cache headers, but I’m a bit lazy for that right now.  See, they’re forcing me to waste their bandwidth.

<?php
 if (!isset($_SERVER['PHP_AUTH_USER']))
 {
   header('WWW-Authenticate: Basic realm="My Realm"');
   header('HTTP/1.0 401 Unauthorized');
   echo 'You are NOT authorized.';
 }
 else
 {
   header('Content-type: text/xml');
   $ch = curl_init("https://mail.google.com/mail/feed/atom");
   curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
   curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
   curl_setopt($ch, CURLOPT_USERPWD, $_SERVER['PHP_AUTH_USER'].':'.$_SERVER['PHP_AUTH_PW']);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   echo preg_replace('/(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)/e',
     'str_replace(\'T24:\', \'T01:\', \'$1\')', curl_exec($ch));
 }
?>

Leave a comment


Accepts BBCode with a few enhancements.