Search code examples
jqueryflickr

Trying to modify the "ptflickrgallery" jQuery plugin to automatically obtain Flickr Photosets


The plugin at http://ptflickrgallery.sourceforge.net/web/index.html does what I need in regard to the displaying of Flickr albums and photos, with slideshow options, thumbnails and so on, but I am just trying to automate the filing in of the Photoset IDs.

I have played with the jQuery.flickrGallery.js provided with the plugin to try and get the Photoset IDs using the Flickr API:

flickr.photosets.getList

but I just can't code it in to the right part of the script to get it to pull in the "set.id" instead of requiring it as a user-defined option.

Could anybody help out with this? I know it will be easy for an experienced jQuery person as everything else is already provided in the script and it's just getting the values from the API into the right array.

I have searched extensively but just don't have the experience to incorporate what I've found in to the script.

Thanks in advance.


MORE INFO I have created a fiddle which displays the four specified albums. The code also displays a list of ALL the photosets automatically using the following code:

    $.getJSON("http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=219c34db9c690cd1977cfc0b1796c7b5&user_id=25234719@N03&format=json&jsoncallback=?", function (data) {
       var list = $("<div id='sets'>");
            $.each(data.photosets.photoset, function (i, set) {
             var li = (set.id);
             $(list).append("'").append(li).append("',");

        });
        $("#flickr-sets").append(list);
    });

What I need is to be able to get the automatic photoset IDS used instead of the manually provided ones...

http://jsfiddle.net/RFG8F/

Any takers?


Solution

  • I try to like this jsfiddle. Is this what you want?

    function getFlickerPhotosId(api_key, user_id, callback){
        var url = "http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=" + api_key +"&user_id=" + user_id + "&format=json&jsoncallback=?";
        $.getJSON(url, function (data) {
            var ids = [];
            $.each(data.photosets.photoset, function (i, set) {
                ids.push(set.id);
    
            });
            callback&&callback(api_key, ids);
        });
    };