javascript - How to get pictures from the flickr API - Stack Overflow

My goal is to bring in photos based on a search of 5 different words; 5 photos each word. I need to bri

My goal is to bring in photos based on a search of 5 different words; 5 photos each word. I need to bring the pictures back into my site; preferably smaller versions as I will bring many files in.

I am new to rest services in general. I saw this option:

.photos.search.html

and I go to the API explorer link at the bottom:

.photos.search

and put in 猫 (meaning cat) for the text field and number of pictures per page at 5 and pages 1, so I would only get back 5 images. This gives me this XML link:

/?method=flickr.photos.search&api_key=4aa062c1cd2da6075e27b599f583665a&text=%E7%8C%AB&per_page=5&page=1&format=rest&api_sig=9f1beab3f0da8f620e197104eb81aa2a

My question would be what would I do with this request? It looks like it is giving ample information to be able to locate each image, but how would I use this XML to pull the images directly into my site?

My goal is to bring in photos based on a search of 5 different words; 5 photos each word. I need to bring the pictures back into my site; preferably smaller versions as I will bring many files in.

I am new to rest services in general. I saw this option:

https://www.flickr./services/api/flickr.photos.search.html

and I go to the API explorer link at the bottom:

https://www.flickr./services/api/explore/flickr.photos.search

and put in 猫 (meaning cat) for the text field and number of pictures per page at 5 and pages 1, so I would only get back 5 images. This gives me this XML link:

https://api.flickr./services/rest/?method=flickr.photos.search&api_key=4aa062c1cd2da6075e27b599f583665a&text=%E7%8C%AB&per_page=5&page=1&format=rest&api_sig=9f1beab3f0da8f620e197104eb81aa2a

My question would be what would I do with this request? It looks like it is giving ample information to be able to locate each image, but how would I use this XML to pull the images directly into my site?

Share Improve this question edited Apr 27, 2017 at 14:55 shellwe asked Apr 27, 2017 at 5:52 shellweshellwe 1154 silver badges16 bronze badges 2
  • why do you need to work with this api if you don't know what to do with the request? – madalinivascu Commented Apr 27, 2017 at 5:56
  • What I need is to send a search out for a Chinese character the user asked for and get back just the images and there aren't really a lot of services out there that can do that without charging a fair amount (considering I'll be pulling down 20 images per search and we will have several classrooms of students use this). I have no idea if this will be able to do what I need but I am taking it one step at a time. I want to avoid scraping images because right now there is no backend or DB and if I can avoid that it would be nice. – shellwe Commented Apr 27, 2017 at 14:32
Add a ment  | 

1 Answer 1

Reset to default 7

shellwe --

After making the request, you'll need to use the information returned to you and build the 'Photo Source URL' (see: https://www.flickr./services/api/misc.urls.html)

In essence, you'll want to loop through the response and build the photo url.

As an example, using the first line item provided in your link:

https://farm{farm-id}.staticflickr./{server-id}/{id}_{secret}.jpg

would be:

https://farm5.staticflickr./4218/35419029800_7a39f756be.jpg

How you incorporate the final photo urls into your website ultimately depends on how you've got things set up.

Hope this helps some.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744921435a4601156.html

相关推荐

  • javascript - How to get pictures from the flickr API - Stack Overflow

    My goal is to bring in photos based on a search of 5 different words; 5 photos each word. I need to bri

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信