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);
}
}
?>
[...] RosSoft » Flickr Component A CakePHP component for working with flickr (tags: cakephp component flickr) [...]
buy oxycontin online
[...] 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 [...]
are there any other free alternatives for flickr to build photogalery?
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
hi. do you have any idea how to use authentication on this?
thanks
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);
}
}
?>
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’));
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?
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
says, this is the main line that needs to be modified: App::import(’Vendor’, ‘phpFlickr’, array(’file’ => ‘phpflickr’.DS.’phpFlickr’.DS.’phpFlickr.php’));
Just made it work with the newest version… here it is:
http://pastebin.com/f5eb7ff2f
Cheerio