Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 1.50 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. class FlickrAPIWrapper {
  4.  
  5.     /**
  6.      * get photos list.
  7.      *
  8.      * @param $user_id The NSID of the user who's photos to return.
  9.      * @param $api_key Your API application. See here. http://www.flickr.com/services/api/misc.api_keys.html
  10.      * @param $per_page Number of photos to return per page.The maximum allowed value is 500.
  11.      * @param $size Size Suffixes. See here. http://www.flickr.com/services/api/misc.urls.html
  12.      */
  13.     public static function getPhotoList($user_id, $api_key, $per_page, $size) {
  14.  
  15.         $feed = simplexml_load_file("http://api.flickr.com/services/rest/?&method=flickr.people.getPublicPhotos&api_key=" . $api_key . "&user_id=" . $user_id . "&per_page=" . $per_page);
  16.  
  17.         foreach ($feed->photos->photo as $key => $item) :
  18.  
  19.         $info = simplexml_load_file("http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=" . $api_key . "&photo_id=" . $item['id']);
  20.  
  21.         echo '<a target="_blank" href="http://www.flickr.com/photos/' . $user_id . '/' . $item['id'] . '">';
  22.         echo '<div class="flickr_box">';
  23.         echo '<img src="http://farm' . $item['farm'] . '.static.flickr.com/' . $item['server'] . '/' . $item['id'] . '_' . $item['secret'] . '_' . $size .'.jpg" />';
  24.         echo '<p class="title">';
  25.         echo $info -> photo -> title;
  26.         echo '</p>';
  27.         echo '<p class="pubdate">';
  28.         echo date('Y-m-d H:i:s', (int)$info -> photo -> dates['posted']);
  29.         echo '</p></div></a>';
  30.         echo "\n";
  31.  
  32.         endforeach;
  33.     }
  34.  
  35. }
  36.  
  37. ?>