Flickr API Wrapper

There are already a couple PHP Flickr API classes out there, but they all seemed a bit over-complicated. Flickr has already done all the work for us, so why make it harder than it is. They've even got all the documentation, so if you ever need to know anything about it, just head over there.

Download Class

This class makes making a request to Flickr's API very simple. And it returns the results as a PHP object. It will even cache your requests so you aren't hitting Flickr as often, thus increasing the speed and performance of this script.

<?php

$api_key = 'your_flickr_api_key_here';

$flickr = new Flickr($api_key);

$params = array
(
'user_id' => 'your_flickr_user_nsid_here',
'extras' => 'url_m,url_sq',
'per_page' => 10,
);

$result = $flickr->call('people.getPublicPhotos', $params);

foreach ($result->photos->photo as $photo)
{
$p = $flickr->call('photos.getInfo', array('photo_id' => $photo->id));

echo '<h2>'.$photo->title.'</h2>';
echo '<a href="'.$photo->url_m.'"><img src="'.$photo->url_sq.'" alt="" /></a>';
echo nl2br($p->photo->description->_content);
}

// Example using chaining

$result = Flickr::factory($api_key)->call('people.getPublicPhotos', $params);

For a live demo, just check out my sidebar over on the right.


Comments

  • Sven Walter Sven Walter November 8, 2011

    it seems that the download link is dead... i am interested in this script. could you reupload it? thank you and nice page :)


Add Comment

  • (optional)