One step closer to world domination
Newest LiveJournal Images
This script displays the newest images posted by LiveJournal users. The script is pretty basic and simply parses a feed from LiveJournal.
You can view it in action here: http://mattdanger.net/lj/ (Warning: Some images may be NSFW!)
The code:
<?php $n = 5; // Maximum is 250 $referrer = 'http://example.com'; // Your site $email = 'user@example.com'; // Your email if ($fp = fsockopen('livejournal.com', 80)) { fputs($fp, "GET /stats/latest-img.bml HTTP/1.0rn" . "Host: www.livejournal.comrn" . "User-Agent: " . $referrer . "; " . $email . "rnrn"); $data = ''; while(!feof($fp)) { $data .= fgets($fp); } fclose($fp); preg_match_all("<recent-image img='([^']+)' url='([^']+)' />", $data, $out); for ($i = 0; $i < $n; $i++) { echo '<a href="' . $out[2][$i] . '"><img border="0" src="' . $out[1][$i] . '" /></a><br /><br />' . "n"; } } else { echo "Connecting to LiveJournal failed."; } ?>
As an aside, if you’re a LiveJournal user and don’t want your images posted to the public feed you can go to your command console and type “set latest_optout yes”.
| Print article | This entry was posted by Matt Danger on November 24, 2004 at 12:54 pm, and is filed under PHP, Unix. Follow any responses to this post through RSS 2.0. Both comments and pings are currently closed. |
Comments are closed.










