views:

324

answers:

1

I create a Flickr account, create an app and got my API key, created a few photo sets and tested the API call using their API explorer to get the following URL to call:

http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=65746342db5d734353b08cd63398a4b4&user_id=21466829@N07&format=json

In the browser this works great, but calling this via jQuery returns absolutely nothing - checked it using FireBug.

Here is my jQuery code:

var url = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=78ac01418165186ee9be695c61a5d53f&user_id=21466829%40N07&format=json';
  $.getJSON(url, function (data) {
    var list = $("<ul></ul>");
    $.each(data.photosets.photoset, function (i, set) {
      var link = $("<a/>").attr("title", set.description._content)
        .attr("href", "http://www.flickr.com/photos/mjryall/sets/" + set.id)
        .text(set.title._content);
      var li = $("<li/>").append(link).append(" (" + set.photos + ")");
      $(list).append(li);
    });
    $("#flickr-sets").append(list);
  });

I have also set the website, tag and permissions to public for this app. This should be a no brainer - what am I missing here?

+2  A: 

Add "&nojsoncallback=1" to the end of your url and it should work.

The problem is, without it Flickr is returning the data with a function wrapper. The jsoncallback param tells it to send you raw JSON.

See the "Callback Function" section here: http://www.flickr.com/services/api/response.json.html

chrissr
I just found that - damn that was annoying!
Slee