如何通过json检索flickr图像的图像描述

发布于 2024-10-18 13:03:01 字数 1151 浏览 2 评论 0原文

检索图像,

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

我正在使用以下 json url 从 flickr 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", "secret":"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"})

我还需要通过 json 获取图像描述。我不知道该怎么办。我尝试了 flickr 提供的所有 json url。如果有任何 flickr 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", "secret":"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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

楠木可依 2024-10-25 13:03:01

要获得标题,您需要做的是:

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

或在 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');

});

然后对于描述,请使用 http://www.flickr.com/services/api/flickr.photos.getInfo.html
photos.getInfo(一个额外的 API 调用)并以这种方式从每张图片中检索描述

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

在你怀里撒娇 2024-10-25 13:03:01

您可以查看此工作示例

You can check this working sample.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文