Displaying Flickr photos
To search photos from Flickr, we will use the Flickr tags search API. The API is very simple to implement and provides the JSON format in response apart from XML. Since we will have to make a cross-domain request in order to contact the API, we will use JSONP to fetch the data. The Flickr API allows a callback parameter in the URL for JSONP requests. To implement the Flickr API, go to the initFlickr
method in your file and write the following code inside it:
$.getJSON('https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?', { tags: 'cat', format: 'json' }, function(data) { var str = ''; $.each(data.items, function(i,item) { str+= '<li>'; str+= '<a class="media" href="javascript:;" data-img="' + item.media.m + '">'; str+= '<img src="' + item.media.m + '">'; str+= '</a>'; var permaLink = '<a href="' + item.link +'" target="_blank">link</a>'; str+= '<strong>'+item.title+'...