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);
    }
}
?>

About these ads

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

7. eyermonkey - November 5, 2008

Note that vendor() is now depracated. It has been replaced by App::import(). Here is the updated code:

‘phpflickr’.DS.’phpFlickr’.DS.’phpFlickr.php’));

//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);
}
}
?>

8. eyermonkey - November 5, 2008

Looks like that didn’t work. Let’s try this:

http://pastebin.com/f6a78f859

The main line that needs to change is this:

App::import(‘Vendor’, ‘phpFlickr’, array(‘file’ => ‘phpflickr’.DS.’phpFlickr’.DS.’phpFlickr.php’));

9. the new no 2 - December 21, 2008

Looks like that didn’t work. Let’s try this:

http://pastebin.com/f6a78f859

Looks like this has been deleted? Any other places we can find the updated code?

10. Jeremy Blanchard - January 2, 2009

Sorry about that. Let’s try a couple sources this time:

http://pastebin.com/f53e0dcf0

http://trac2.assembla.com/FlickrContestr/browser/trunk/app/controllers/components/flickr.php?rev=21

Like my comment above (number 8) says, this is the main line that needs to be modified: App::import(’Vendor’, ‘phpFlickr’, array(’file’ => ‘phpflickr’.DS.’phpFlickr’.DS.’phpFlickr.php’));

11. To wonder - January 16, 2009

Just made it work with the newest version… here it is:

http://pastebin.com/f5eb7ff2f

Cheerio

12. Forbidden London Clubs - August 23, 2009

Good component! Like it, great for photos of clubs in London as you can see by our guest list website!

13. Your own cakephp file-browser for ckeditor: part 4 – flickr photos and slideshow - August 2, 2010

[…] the FlickrComponent – a bridge to the phpFlick class, that loads it as a cake component – and the chasm […]

14. xymalf - July 22, 2012

what do you save the filename as?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: