webmaster tutorials and internet facts

zend framework flickr tutorial

flickr_logoFlickr is a largest images database with user registration, each user can upload his own images. Flickr became popular because of it’s API and it offers Flickr API development for anyone who wants to add cool features to his website.

Zend framework documentation doesn’t contains information on how to show images actually when looping through flickr search results and we decided to create simple and understandable tutorial on how to show found images results.

To start working with flickr API you will need flickr API key, you can get one here.

We suppose you have your controller class and directories structure to enable MVC zend framework structure for development.

When we preperred our API and have everything to work with Zend framework flickr, let’s create our application.

Here is commented controller code :

<?

public function indexAction() {
// replace YOUR_FLICKR_API with your flickr api, we initializing zend_service_flickr classes
$flickr = new Zend_Service_Flickr(’YOUR_FLICKR_API’);

// we are looking for php at flickr with tagSearch() function
$results = $flickr->tagSearch(”php”);

foreach ($results as $result) {
$this->view->output .= “<img width=’100′ height=’100′ src=’http://farm”.$result->farm.”.static.flickr.com/”.$result->server.”/”.$result->id.”_”.$result->secret.”.jpg’><br>”;

}

}

Now let’s create our view, create file index.phtml in your view directory and type output inside.

<?=$this->output?>

That’s it, now you can create your search engine by creating form with search field, form post variable can replace “php” in our line code $results = $flickr->tagSearch(”php”); And you are done.

Simple isn’t it ? Thanks to zend framework.

Add Twitter response to this post...
Twitter username :   
Twitter password :

Post Metadata

Date
July 14th, 2009

Author
glurt


Leave a Reply