JQuery / Flickr API issue with photoset

I am trying to build a photo album system managed through Flickr, I spent the last day or so playing with the Flickr API, and I have the following code, but it just does not return the expected HTML. insetad I get an error in my browser for the line above ($ ('# images'). html (theHtml);)

  <script type="text/javascript">
     $(document).ready(function(){

   $.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxx&photoset_id=xxxxxxxxxxxxxxxxxxxx=&format=json&jsoncallback=?', displayImages);

   function displayImages(data) {

    var photosetID = "";
    var title = "";
    var theHtml = "";
    $.each(data.photosets.photoset, function(i,set){

     photosetID = set.id;
     title = set.title._content;
     ids.push(photosetID);
     titles.push(title);

     var sourceSquare = (set.media.m).replace("_m.jp g", "_s.jp g");

     theHtml+= '<li><a href="'+set.link+'" target="_blank">';
     theHtml+= '<img title="'+set.title+'" src="'+sourceSquare+'" alt="'+set.title+'" />';
     theHtml+= '</a></li>';
    });

    $('#images').html(theHtml);    });   });

  </script>

I also saw examples using something like this:

$.getJSON("http://api.flickr.com/services/feeds/groups_pool.gne?id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx&lang=en-us&format=json&jsoncallback=?", displayImages);

BUt was not sure what the group identifier is, is it the same as the set identifier? As Flickr knows who I am in example two, since I do not see any API being passed.

My preference would be to get the first example to work, as that is what I worked on, but any advice / example would be apprieciated

amuses

+3
2

, api, rss-. . flickr api photosets.getPhotos

:

$.getJSON(url, function(data) {
    $.each(data.photoset.photo, function(i,item){
    var squareUrl = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '_s.jpg';
    var largeUrl = squareUrl.replace('_s.jpg', '_b.jpg');
});
+7

, , ... Code is here ...!

0

Source: https://habr.com/ru/post/1756963/


All Articles