0

I have two websites populating galleries via a simple FlickrAPI call with JSON and jQuery. They've been chugging along happily for the last couple years, but they both started throwing an error last week, causing gallery population to fail.

I've isolated the problem to being related to a call to photosets.getInfo.photo.description. Other requests are working fine: requesting an image with the tag 'featured', text descriptions, all working as expected.

Here's the explicit call:

$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=' + apiKey + '&photo_id=' + rPhoto.id + ' &format=json&jsoncallback=?', function(data){
    var PhotoDescription=data.photo.description._content.replace(/\n/g, "<br />");
    ...

}

and the error reads:

Uncaught TypeError: Cannot read property 'description' of undefined 

As this problem popped up on multiple sites at once, I think I can assume there's been some change on the Flickr side that I need to accommodate somehow, but I can't find any documentation for such a change, or anyone else who's experiencing the same issue.

Thanks so much in advance for any hints or help! Stacey

sdowswell
  • 101
  • 12
  • Flickr API has not changed. Are you sure your API key is still valid, or something is not preventing you from accessing the site? I would first try accessing the URL directly from a browser to see what is wrong. I would also add error handling into the getJSON function as well just in case (see Luciano's answer here: http://stackoverflow.com/questions/1740218/error-handling-in-getjson-calls) – mccannf Jan 11 '13 at 14:51
  • 1
    You may also need error handling if the photo in question is not found: `{"stat":"fail", "code":1, "message":"Photo \"\" not found (invalid ID)"}` – mccannf Jan 11 '13 at 15:14
  • Call is executing fine, and other API calls are running smoothly. Error seems limited to photo object traversing. I'll add error handling (good idea anyways), but want to note that problem is not that API is inaccessible. – sdowswell Jan 11 '13 at 16:24

1 Answers1

1

Looks like the image secret is required in the request as well. Updated JSON request to reflect this:

$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=' + apiKey + '&photo_id=' + rPhoto.id + '&secret=' + rPhoto.secret + '&format=json&jsoncallback=?', function(data){...}

Seems to be working fine now. (also added error handling for future issues.)

sdowswell
  • 101
  • 12