Flickr JSON parsing - noob!
in
Contributed Library Questions
•
1 year ago
Hello all.
I'm new to programming and i need some help from the gurus / sifus / anyone at all.
I'm trying to parse flickr json to get metadata of the photos. I tried google - but no luck getting an answer. So, I thought maybe posting my question here would help me get the info i need. Any input would be greatly appreciated.
Here's what i have so far.
import org.json.*;
String api = "http://api.flickr.com/services/rest/?method=flickr.photos.search&";
void setup() {
getFlickrData();
}
void getFlickrData() {
String request = api + "&tags=sky&has_geo=1&per_page=25&format=json&nojsoncallback=1&extras=geo&api_key=*******";
println(request);
String result = join( loadStrings( request ), "");
//println(result);
try {
JSONObject flickrData = new JSONObject(join(loadStrings(request), ""));
//JSONArray photos = flickrData.getJSONArray("photos");
println(flickrData.getString("photos"));
/*
for (int i = 0; i < photos.length(); i++){
JSONObject flickrImg = (JSONObject) photos.get(i);
JSONArray flickrPhoto = flickrImg.getJSONArray("photo");
JSONObject photo = (JSONObject) flickrPhoto.get(0);
println("\nLongitude : " + photo.getString("longitude"));
} */
}
catch (JSONException e) {
println ("There was an error parsing the JSONObject.");
};
};
1