Get photos from flickr.photos API?
Asked Answered
H

2

6

I want to list photos from flickr account using flickr.photos API using PHP with OAuth.

Right now to get the URLs of the images I am doing it in 2 steps which makes too many requests to the API and takes too much time:

  1. First I request the photos using flickr.photos.search
  2. then I loop the array of results and call the flickr.photos.getInfo for each photo apart. [result of flickr.photos.search] does not return URL of images, but getInfo does.

Is there a way to get the images with one single request?

Thanks!

Hospers answered 24/1, 2014 at 8:46 Comment(0)
H
16

Found the solution, described here: Flickr Image URLs

You can construct the source URL to a photo once you know its ID, server ID, farm ID and secret, as returned by many API methods.

The URL takes the following format:

http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}.jpg
    or
http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}_[mstzb].jpg
    or
http://farm{farm-id}.staticflickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png)

You can find examples and image size prefixes as well on the source page.

Hospers answered 24/1, 2014 at 9:4 Comment(1)
In this, how define it is 'jpg' or 'gif' or 'png'? Before this, we calling getPhotos($user_id, $args); This function is not return the extension. Any other method to get extension of the file?Grunt
T
-1

If you are planning use Angular, There is an npm package that make you the job.

Checkout it on npm site: https://www.npmjs.com/package/angular-flickr-api-factory

Trochilus answered 18/3, 2017 at 17:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.