开发者

How to retrieve image description of flickr image via json

I am using Following json url to retrieve images from flickr

http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=***&photoset_id=72157625776815845&extras=original_format&format=json&jsoncallback=?

Response

jsonFlickrApi({"photoset":{"id":"72157625776815845", "primary":"5386650651", "owner":"58668842@N05", "ownername":"mohanramphp", "photo":[{"id":"5386650651", "secret":"fcfc73c14f", "server":"5214", "farm":6, "title":"image5", "isprimary":"1"}, {"id":"5387254114", "secret":"76e63d565e", "server":"5215", "farm":6, "title":"image4", "isprimary":"0"}, {"id":"5386650273", "sec开发者_开发技巧ret":"2f0d19575a", "server":"5214", "farm":6, "title":"image3", "isprimary":"0"}, {"id":"5387253836", "secret":"66f2ec20a7", "server":"5214", "farm":6, "title":"image2", "isprimary":"0"}, {"id":"5387253676", "secret":"f159c8d52a", "server":"5212", "farm":6, "title":"image1", "isprimary":"0"}], "page":1, "per_page":500, "perpage":500, "pages":1, "total":"5"}, "stat":"ok"})

I need to fetch image description also via json. I don't know how to do. I tried all json url provided by flickr. If there is any flickr json to retrieve image description intimate myself.


What you have to do to get the title is:

titles=[]
ids=[]
photoset.each do |photo|
titles<<photo.title
ids<<photo.id
end

or in jQuery:

    var items = [];
    $.getJSON(url, function(data) {
        if (data.photoset==null)
        {
        alert("you didnt freakin do it right!!")
        }
        else
        {
        $.each(data.photoset.photo, function(){

        items.push('<li id="' + this['id'] + '">' + this['title']</li>');
          });

          $('<ul/>', {
            'class': 'my-new-list',
            html: items.join('')
          }).appendTo('body');

});

and then for the description, use the process outlined in http://www.flickr.com/services/api/flickr.photos.getInfo.html photos.getInfo (an additional API call) and retrieve the description from each picture that way


You can check this working sample.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜