Skip to content

Instantly share code, notes, and snippets.

Created January 26, 2012 21:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1685091 to your computer and use it in GitHub Desktop.
Save anonymous/1685091 to your computer and use it in GitHub Desktop.
Google Reader JSON to bookmarks.html
<?php
// bump this limit up as it can be quite memory intensive if you have a lot of shared items
ini_set('memory_limit', '64M');
// update to use your own file here
$json_file = "/tmp/shared-items.json";
// output the std header
// http://msdn.microsoft.com/en-us/library/aa753582(v=vs.85).aspx
echo <<< EOT
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<Title>Bookmarks</Title>
<H1>Bookmarks</H1>
EOT;
$json = json_decode(file_get_contents($json_file));
echo "<DL>\n\t";
foreach ($json->items as $item) {
$url = str_replace('&', '&amp;', $item->alternate[0]->href);
echo "\t<DT><A HREF=\"".$url.'" ADD_DATE="'.$item->published.'" LAST_VISIT="'.round($item->crawlTimeMsec/1000).'" LAST_MODIFIED="'.$item->updated.'">'.utf8_decode($item->title)."</A></DT>\n";
}
echo "</DL>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment