Skip to content

Instantly share code, notes, and snippets.

@anthonyterrell
Created March 24, 2013 23:13
Show Gist options
  • Save anthonyterrell/5234014 to your computer and use it in GitHub Desktop.
Save anthonyterrell/5234014 to your computer and use it in GitHub Desktop.
Flickr set component for CakePHP
<?php
/**
* Flickr Component
*
* This file will share logic to your controller
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Controller
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Component', 'Controller');
class FlickrComponent extends Component {
public function set() {
/**
*
* Grab URL to your photo set
* Reference: http://www.flickr.com/services/api/explore/flickr.photosets.getPhotos
*/
$url = 'add your url here';
$photos = json_decode(file_get_contents($url));
return $photos;
}
}
@anthonyterrell
Copy link
Author

I left this in object notation instead of a PHP array in order to easily access the nested elements. If you'd like to convert the outcome to a PHP array you could use this:

$photos = json_decode(file_get_contents($url), TRUE);

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment