Using SimplePie to access shared items in Google Reader

This is a quick overview on how to access your shared items in Google Reader using PHP. Since Google Reader publishes your shared items to a RSS feed, we can access your feed using a PHP library called SimplePie.

You can trivially connect to your shared items feed with the following lines of code:

$feed = new SimplePie();
$items = $feed->get_items();

We can then loop through the items and easily grab the Title, Author, and Link of the shared item.

foreach($items as $item)
  $data = $item->get_item_tags( SIMPLEPIE_NAMESPACE_ATOM_10, "source" );
  $link = $data[0]['child']['']['link'][0]
  $created = $data[0]['child']['']['title']
  $title = $item->get_title();
  $content = "<a href=\"".$item->get_permalink()."\">".$item->get_title()
                       ."</a> (<a href=\"$link\">$created</a>)";

Google Reader, also, allows you to post a note to any item that you share in Google Reader. This is, also, conveniently put into the shared-item RSS Feed which we can grab using SimplePie.

$note_data = $item->get_item_tags(
                      "annotation" );
$note = $note_data[0]["child"][""]