Created
January 26, 2012 21:02
-
-
Save anonymous/1685091 to your computer and use it in GitHub Desktop.
Google Reader JSON to bookmarks.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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('&', '&', $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