Flickr API WrapperJuly 27, 2009 | Posted in Freebies, PHP
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.
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.
$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 '<a href="'.$photo->url_m.'"><img src="'.$photo->url_sq.'" alt="" /></a>';
// 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.