Using phpFlickr to Integrate Flickr Photos on Your Own Site

Written By: Jay

- 21 Oct 2006 -
















Description: In this tutorial I will explain how to use the phpFlickr API to interact with Flickr and display photos on a web site.

  1. Summary and Requirements
  2. History
  3. Getting Started
  4. How Does This Work
  5. On Your Own

Getting Started

It is important to point out that you need to first authenticate your application with Flickr and obtain the API key information. For simple reading of public photos it's as simple as registering your app here but getting full read/write access is a bit more involved and I will skip that for now.

You can see the fully working example site .

phpFlicker detailed instructions are here but I'll give you the gist of it.

  1. First you need to have the PEAR packages installed on your server.
  2. Extract the phpFlickr archive to you working folder.
  3. Create an index.php file and include the phpFlickr.php file:

require_once("phpFlickr/phpFlickr.php");

  1. Add some user credentials:

$username = "username";
$apiKey = "[APIKEY]";
$apiSecret ="[APISECRET]";

  1. Instantiate the phpFlickr object:

// Create new phpFlickr object
$f = new phpFlickr($apiKey,$apiSecret);

  1. Enable the cache DB:

$f->enableCache("db","mysql://[USERNAME]:[PASSWORD]@[SERVER]/[DATABASE]");

  1. Get the nsid from the username:

$nsid = $f->people_findByUsername($username);

You now have a phpFlickr object ($f) and a userid object ($nsid). Your next step will be to retrieve a PhotoSet object and display a thumbnail from each of your Photo Sets.

<< Previous

Next >>