public
Last active

fetch flickr photos in javascript & put them on a page.

  • Download Gist
gistfile1.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<!-- fetch flickr photos in javascript & put them on a page. Based on Jon LeBlanc's PHP code: http://developer.yahoo.net/blog/archives/2010/04/building_flickr_urls_from_yql_flickrphotossearch_results.html -->
 
<body>
<script>
function cbfunc(obj){
for(var i = 0; i < obj.query.results.photo.length; i++){
var farm = obj.query.results.photo[i].farm;
var server = obj.query.results.photo[i].server;
var id = obj.query.results.photo[i].id;
var secret = obj.query.results.photo[i].secret;
var img = new Image();
img.src = 'http://farm'+farm+'.static.flickr.com/'+server+'/'+id+'_'+secret+'.jpg';
document.body.appendChild(img);
}
}
</script>
<script src='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20flickr.photos.search%20where%20has_geo%3D%22true%22%20and%20text%3D%22ucsd%22%20and%20safe_search%3D%22true%22&format=json&diagnostics=false&callback=cbfunc'></script>
</body>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.