// simple flickr image search demo - November 2011 - rtwomey@u.washington.edu // // flickr API details here: // http://www.flickr.com/services/api/ // // register for a developers key here: // http://www.flickr.com/services/apps/create/apply/ void setup() { size(800, 800); background(0); String baseURL = "http://api.flickr.com/services/rest/?"; // address for flickr web services String apiMethod = "flickr.photos.search"; // search flickr photos String apiKey = "bd7435660785b923332b224789d33c93"; // this key was floating around processing.org, bad form String tagString="paris"; // search string String query = baseURL+"method="+apiMethod+"&tags="+tagString+"&api_key="+apiKey+"&per_page=4"; // do actual query call XMLElement xml = new XMLElement(this, query); // holds the results //println(xml); // gather results XMLElement[] photoTag = xml.getChildren("photos/photo"); // get just the photos println(photoTag.length + " images"); //loop over images for (int i = 0; i < photoTag.length; i++) { String farm = photoTag[i].getString("farm"); String server = photoTag[i].getString("server"); String id = photoTag[i].getString("id"); String secret = photoTag[i].getString("secret"); String img = "http://farm"+farm+".static.flickr.com/"+server+"/"+id+"_"+secret+".jpg"; PImage tmp; tmp = loadImage("http://farm"+farm+".static.flickr.com/"+server+"/"+id+"_"+secret+".jpg"); image(tmp, i*200, i*200); // alternately, save me for later. see flickr_api_array.pde } } void draw() { }