jump to navigation

Flickr Component June 4, 2006

Posted by rossoft in CakePHP.
trackback

Flickr component for easy integration of phpFlickr

You will have access to phpflickr instance in your controllers: $this->flickr, and in your views: $flickr.

It will use the dir app/tmp/cache/flickr for caching

1. Copy phpFlickr to app/vendors/phpflickr/

2. Copy this to app/controllers/components/flickr.php and change the api key to yours (you can get your api key in https://sourceforge.net/project/showfiles.php?group_id=139987 )

<?php

/**
 * Flickr Component
 * @author RosSoft
 * @license MIT
 * @version 0.1
 */
define(’FLICKR_CACHE_DIR’,CACHE . ‘flickr/’);

class FlickrComponent extends Object
{
    /**
     * Api Key. Change to your own
     * @var string
     * @link http://www.flickr.com/services/api/misc.api_keys.html
     */
    var $_api_key=’CHANGE_TO_YOUR_KEY’;

    function startup(&$controller)
    {
        vendor(’phpflickr/phpFlickr’);
   
        //FlickrComponent instance of controller is replaced by a phpFlickr instance
         $controller->flickr =& new phpFlickr($this->_api_key);
         if (!is_dir(FLICKR_CACHE_DIR))
        {
            mkdir(FLICKR_CACHE_DIR,0777);
        }                
         $controller->flickr->enableCache(’fs’, FLICKR_CACHE_DIR);
         $controller->set(’flickr’,$controller->flickr);
    }
}
?>

Comments»

1. Richard@Home » Blog Archive » links for 2006-06-06 - June 6, 2006

[...] RosSoft » Flickr Component A CakePHP component for working with flickr (tags: cakephp component flickr) [...]

2. buy oxycontin online - March 7, 2007

buy oxycontin online

3. developercast.com » SitePoint: Build a Photo Gallery Using CakePHP and Flickr - April 6, 2007

[...] steps the reader through the tools needed (including the Flickr Component for CakePHP) and how to get things set up and working together. With just a few simple calls to the [...]

4. Arius - April 20, 2007

are there any other free alternatives for flickr to build photogalery?

5. louie - May 8, 2008

I got this error.

Fatal error: Cannot instantiate non-existent class: phpflickr in /home/www/app/controllers/components/flickr.php on line 25

I am using CakePHP 1.2

6. louie miranda - August 1, 2008

hi. do you have any idea how to use authentication on this?

thanks