One step closer to world domination
Posts tagged LiveJournal
Newest LiveJournal Images
Nov 24th
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”.










