<?php
/**
Copyright (c) 2010 Tibor Szász

License: MIT License

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
     
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
       
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
           
header'Content-type: text/xml; charset=UTF-8');

// This is typically the first segment of your gMail address 
// OR your profile ID that you can figure out by clicking on your name in Buzz
$account_id     'tszasz'
$feed_title     'Google Buzz items by Tibor Szász';
$google_profile 'http://www.google.com/profiles/'.$account_id;
$feed_desc      'My Google Buzz shares, get real! :)';

$buzz 'http://buzz.googleapis.com/feeds/'.$account_id.'/public/posted';
$feed file_get_contents$buzz );
$xml  simplexml_load_string($feed);

$glob_date date'D, d M Y H:i:s'strtotime$xml->entry[0]->published ) );

$rss "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'> 
<channel>
  <atom:link href='http://"
.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."' rel='self' type='application/rss+xml' />
    <title>{$feed_title}</title> 
    <link>{$google_profile}</link> 
    <description>{$feed_desc}</description> 
    <language>en-us</language>
    <pubDate>{$glob_date} GMT</pubDate> 
    <lastBuildDate>{$glob_date} GMT</lastBuildDate> 
    <docs>http://blogs.law.harvard.edu/tech/rss</docs> 
    <generator>Kow's Google Buzz to RSS converter</generator>"
;

//var_dump($xml);

foreach( $xml->entry as $item )
{
    
$pubdate date'D, d M Y H:i:s'strtotime$item->updated ) );
$rss .= "\n\t<item> 
         <title>{$item->title}</title> 
         <link>{$item->link['href']}</link> 
         <description><![CDATA[{$item->content}]]></description> 
         <pubDate>{$pubdate} GMT</pubDate> 
         <guid isPermaLink='false'>{$item->id}</guid> 
      </item>"
;
}

$rss .= "\n</channel></rss>";

// Print output
echo $rss;
// End of script