Get Flickr image parameters from json format into variables
I'm a little confused right now. I've looked at jQuery documentation,
Flickr documentation, and a bunch of similar examples online, but it's not
clear to me what I'm missing here.
Basically, I want to return the parameters for a single photo and put
specific ones into variables. In my test, I started with an alert to make
sure it was returning the data, but I can't get it to work.
$.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photos.getInfo&api_key='
+ apiKey + '&photo_id=' + photoId + '&format=json&jsoncallback=?',
function(data) {
alert(data.photo.id);
});
and here's a sample of data that is returned from the url above
jsonFlickrApi({
"photo":{
"id":"9691687487",
"secret":"38a52fd5ae",
"server":"3700",
"farm":4,
"dateuploaded":"1378570461",
"isfavorite":0,
"license":"4",
"safety_level":"0",
"rotation":0,
"originalsecret":"a2fb99d8e4",
"originalformat":"jpg",
"owner":{
"nsid":"41141575@N03",
"username":"helmuthess",
"realname":"",
"location":"",
"iconserver":"5457",
"iconfarm":6,
"path_alias":"helmuthess"
},
"title":{
"_content":"Splash"
}...
I get an error
Uncaught TypeError: Cannot read property 'id' of undefined
And I've tried the redefining what I'm trying to access, thinking I just
don't understand the correct way, but I always get that something is
undefined.
Also, when I just do alert(data); it shows [object Object]
Any clarification on what I'm not understanding would be much appreciated.
No comments:
Post a Comment