Search code examples
jqueryjsonflickr

jQuery: jsonFlickrFeed not working


I am trying to call my photos in flicker so I could use them in my photo gallery.

But my code does not retrieve anything.

I watched it from lynda.com I included this line of code

<script src="http://api.flickr.com/services/feeds/photos_public.gne?id=[MY_ID]&format=json&tags=viewsource">

Note [My_ID] = of course my ID.

When I run it in my browser it shows the jsonFlickrFeed completely with the objects.

However, when I call it in my script

function jsonFlickrFeed(data) {
   console.log(data);
}

Nothing shows up in my console. I need to retrieve the photos so I could display them in my gallery. Thanks


Solution

  • Take a look on getJSON() method, that also has an example to fetch photos from flicker.

    var flickerAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
     $.getJSON( flickerAPI, {
       tags: "mount rainier",
       tagmode: "any",
       format: "json"
     })
     .done(function( data ) {
      $.each( data.items, function( i, item ) {
        $( "<img>" ).attr( "src", item.media.m ).appendTo( "#images" );
        if ( i === 3 ) {
          return false;
        }
      });
    });