Flickr API with PHP

flickr

Share: Share on Facebook5Share on LinkedIn7Tweet about this on Twitter2Share on Google+3Share on Reddit0Buffer this pageDigg thisEmail this to someoneShare on StumbleUpon1Share on TumblrPin on Pinterest0Print this page

Flickr is one of the biggest website for the photostreams and Flickr supports API which is a very easiest way to display photos on your website without having to worry about server bandwidth and performance.

Well,Today I am going to explain how you get photosets from the Flickr with the use of Flickr API.

First of all,Lets get the Flickr API.To get the Flickr API, you need to sign into Flickr and request for an API key. Now you have your own Flickr API

Next is how we get Flickr photosets with using Flickr API.Here, I am going to use cURL to get the data from Flickr. If you don’t want to go with cURL, you can use file_get_contents function.

Let’s have a look into the below code:

In above code, I have defined api_key, you need to replace your Flickr API key with which to sign your requests.Next, method, I used here is flickr.photosets.getList which is one method of Flickr to get a list of a Flickr’s photosets. Third parameter is the user_id of flickr account.Fourth parameter is the format and php_serial format which will return serialized PHP string with the data

Here,To get the data,I have used PHP cURL functions.cURL is a library of allows us to communicate with other servers.curl_init is initialize the cURL handle.In CURLOPT_URL in curl_setopt,to put the url to fetch data by curl library.curl_exec is execute the curl and curl_close is to close the curl. With CURLOPT_RETURNTRANSFER as true means to return the contents in a variable instead of echoing them to the browser.

Here, I have unserialize the contents fetched via API.That’s it. Now you can use fetched details of flickr photos to direcly display on site,even you can create slideshow,gallery etc.

Lets check out the output returned by above code

That’s it.I hope this post will helpful.I hope this post will help you. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Share: Share on Facebook5Share on LinkedIn7Tweet about this on Twitter2Share on Google+3Share on Reddit0Buffer this pageDigg thisEmail this to someoneShare on StumbleUpon1Share on TumblrPin on Pinterest0Print this page

3 thoughts on “Flickr API with PHP”

  1. […] is an image and video hosting website.Few days back, I have explained Flickr API with PHP and I have used same code to create this […]

  2. […] is an image and video hosting website.Few days back, I have explained Flickr API with PHP and I have used same code to create this […]

  3. […] is an image and video hosting website.Few days back, I have explained Flickr API with PHP and I have used same code to create this […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Most Popular Posts

GoTo statement in PHP

Posted on 3 years ago

Bhumi

Table layout using DIV tags

Posted on 2 years ago

Bhumi

Mysql String Function FIND_IN_SET( )

Posted on 3 years ago

Bhumi

Post via e-mail in WordPress

Posted on 3 years ago

Bhumi

New Features in MySQL 5.6

Posted on 3 years ago

Bhumi