Created
March 24, 2013 23:13
-
-
Save anthonyterrell/5234014 to your computer and use it in GitHub Desktop.
Flickr set component for CakePHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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