/ Published in: PHP
It’s been driving me crazy that there’s no definitive script written to take out a user’s Flickr recent photos and parse it for formatting into HTML with a larger size than the standard 75 x 75 dimensions that the public_photo.gne Flickr script outputs. So I’ve written one, using a bit of skill and a snippet of code that someone posted which was kind of going in the same direction but then suddenly stopped and took a hard u-turn, veering off to somewhere stupid, as usual with programmers who know too much. So here’s a quick run through of what the code does:
Collect the User ID that is added manually and constructs the Feed Links
Get the File contents of the Feed Link once it’s been run
Convert the XML to HTML
Return it to the script for printing or a variable (Choice of the Programmer)
I haven’t tested this on different versions of PHP, all I know is it works for me, and it’s using some pretty simple stuff so it should work fine. Just change the ID to your own or whoever’s it has to be and it should run.
Collect the User ID that is added manually and constructs the Feed Links
Get the File contents of the Feed Link once it’s been run
Convert the XML to HTML
Return it to the script for printing or a variable (Choice of the Programmer)
I haven’t tested this on different versions of PHP, all I know is it works for me, and it’s using some pretty simple stuff so it should work fine. Just change the ID to your own or whoever’s it has to be and it should run.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function attr($s,$attrname) { // return html attribute } function getFlickrFeed($id,$n) { $urlenc = urlencode("http://api.flickr.com/services/feeds/photos_public.gne?id=$id&lang=en-us&format=rss_200"); $url = "http://pipes.yahoo.com/pipes/pipe.run?_id=HHvHTP7h2xGPZ1tDdbq02Q&_render=rss&urlinput2=$urlenc"; $out = ""; if($i>=$n) return $out; $item = $items[1][$i]; $link = $temp[1][0]; $title = $temp[1][0]; $thumb = attr($temp[0][0],"url"); $img = $thumb2[0]."_".$thumb2[1].".jpg"; //print $img; $out.="<a href='$link' target='_blank' title=\"".str_replace('"','',$title)."\"><img src='$img'/></a>"; } return $out; } // Example Request with ID and how mant photos required echo getFlickrFeed("33785122@N08",9);
URL: http://www.webchase.co.uk/blog/462/flickr-recent-photos-to-html-with-php