Created
November 14, 2012 13:42
-
-
Save jonesch/4072127 to your computer and use it in GitHub Desktop.
Downloading Flickr photos
This file contains 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 // Let's go get some flickr photos. Key and Set are defined in the uploader. | |
$query = 'http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key='.$apiKey.'&photoset_id='.$photoset_id.'&extras=url_o,url_c&format=php_serial'; | |
$ch = curl_init(); // open curl session | |
// set curl options | |
curl_setopt($ch, CURLOPT_URL, $query); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$data = curl_exec($ch); // execute curl session | |
curl_close($ch); // close curl session | |
$output = unserialize($data); | |
$photos = $output['photoset']['photo']; | |
?> | |
<ul class="photo-carousel"> | |
<?php foreach($photos as $photo) { ?> | |
<li><img <?=($photo['height_c']=="800"||empty($photo['height_c'])?'class="offset-left"':'')?>src="<?=!empty($photo['url_c'])?$photo['url_c']:$photo['url_o']?>" width="<?=!empty($photo['width_c'])?$photo['width_c']:$photo['width_o']?>" height="<?=!empty($photo['height_c'])?$photo['height_c']:$photo['height_o']?>" dwnld_link="<?=$photo['url_o']?>" /></li> | |
<?php } ?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment