Grab Flickr Photos with Javascript!
Michael at mlcastle.net made a nice script called flickr-dom.js. It parses the JSON returned by flickr and output XHTML and DOM compliant code. If that’s all alien to you, don’t fear! Just read on… using it is no where as hard
I’ve put his script together with some css which can be download here.
To grab the images you want from flickr, all you need to do is point the the correct feed. To do this, locate line 27 in flickr-grabber.html. You should see this URL:
http://api.flickr.com/services/feeds/photos_public.gne?tags=starcraft&format=json
This is the feed where the images are being grabbed from. As you can see, there is a part that says “tags=starcraft”. That simply means… grab all public images on flickr that is tagged “Starcraft”.
To narrow the search, and get images tagged with both “Starcraft” AND “Warcraft”, add to that URL more tags separated by commas.
http://api.flickr.com/services/feeds/photos_public.gne?tags=starcraft,warcraft&format=json
To broaden the search and get images tagged either “Starcraft” OR “Warcraft”, add to the URL “&tagmode=any”.
http://api.flickr.com/services/feeds/photos_public.gne?tags=starcraft,warcraft&tagmode=any&format=json
The online documentation for flickr URL feeds can be found here.







My Pakistani friend did something too.
nickpan said this on March 25th, 2008 at 4:42 pm
yea that uses ASP. this is pure client-side… javascript only.
pk said this on March 25th, 2008 at 4:58 pm
means doesn’t need a php or asp environment… you can even view it off your desktop for that matter
pk said this on March 25th, 2008 at 5:00 pm
Okay I didn’t try it but just curious, does it use document.write like the standard flickr badge does? If not, it should be compliant in application/xhtml+xml MIME type, right?
draco said this on March 25th, 2008 at 11:02 pm
not sure what you’re asking heh… but it doesn’t use the javascript document.write() check out http://mlcastle.net/flickr-js-dom-json.html
pk said this on March 26th, 2008 at 12:10 am
good to see you sharing knowledge in your blog. =) keep it up. oh gosh, why am i not sleeping now????
shimmer said this on March 26th, 2008 at 1:18 am
!!! /slap
pk said this on March 26th, 2008 at 1:31 am
@pk: Aww, I should have found out about this earlier when I was looking for an alternative. Now I’m using PHP to generate the photos. Thanks for sharing anyway!
draco said this on March 26th, 2008 at 2:36 pm
[…] Pior to this, i’ve posted on how to “Grab Flickr Photos with Javascript!“ […]
Mashup of Google Map, Flickr, YouTube & Yahoo! Travel said this on April 30th, 2008 at 2:32 pm