jurian sluiman

{
Wissel naar

A new Flickr service for php

Soflomo has built its CMS upon the Zend Framework and because I use Flickr for my on-line gallery, I've done some research into the Zend_Service_Flickr component of ZF. I'd be nice if I could have used it to manage my photos (and sets and collection) to display to all visitors. Unfortunately its structure is very simple, it's more a wrapper around the REST client: you have to make the api calls yourself and get a very common 'result set' from the service back.

I thought it could be done such better with a more O/R like service. You'll have Flickr_Collection, Flickr_Set, Flickr_User and Flickr_Photo objects, all very clear and with distinguished roles. You can ask a set for its photos, a collection for its sets and so on.

Because I'm very open source minded and Soflomo is happy to use the open source ZF product, some of our code will also be published under the new BSD license (just like ZF). The open Soflomo library is called Sozfo and hosted at Google Code. There are more things in the library, but one of them is the Sozfo_Service_Flickr package. You should check out the source and try it yourself, it's actually easy to get some results.

For example, these are some snippets I used to get my gallery online at this website:

$flickr = new Sofzo_Service_Flickr();
$flickr->setKey($apiKey)
       ->setSecret($apiSecret)
       ->setToken($authToken);

$user = $flickr->factory('user');
//$email, $profilepage or $photopage will work as well
$user = $user->find($username);

$set = $flickr->factory('set');
$sets = $set->getList($user);

echo 'Sets for user ' . $user->getUsername();
foreach ($sets as $set) {
  echo '<h2>' . $set->getTitle() . '</h2>';
  echo '<img src="' . $set->getPrimary()->location('thumbnail') . '">';
}

I hope you like the opportunities. Because Flickr recently updated their api with collections support, the Sozfo_Service_Flickr has support for collections! My gallery if updated directly from every change I make at Flickr (with some local cache of course), so no local configuration anymore. Huraay!

Comments

Matthew Weier O'Phinney

Any chance you'd be interested in contributing your modifications and additions back to ZF? I'd love to see a more robust client in the base distribution. :)

Jurian Sluiman

Hi Matthew,

I'd be proud if that's possible! First I'd like to extend the service a bit. The current ZF Flickr service has built in support for tags, mine hasn't. When I have some tags and group features included, I'll make a proposal at the Zend Wiki.

Jurian Sluiman

If your're interested in the future of this service, please view this newer post about the requirements for a proposal.

Oran

Hi Jurian,
I'm trying to use your flickr gallery example in my website, and i\'ve a few questions:

1) I've looked at your Sozfo_Service_Flickr package and my question is where should these classes be located in ZF project?
2) Also where should I locate the sbnippets above in my code?

Thanks ahead,
Oran

Place a comment

If you have a user account for this site, you can login to click here.

Please note your comment below will be removed if you login!

 
 

The address is stored internally but not displayed on this site. We will respect your privacy.

In your message no html is allowd. A blank line creates a new paragraph, an url gets a hyperlink.