Posted By

mzym on 09/22/09


Tagged

php Smarty flickr photos api


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Priestd09


Photo Gallery via flickr API


 / Published in: PHP
 

  1. require_once("phpFlickr/phpFlickr.php");
  2.  
  3. $username = "";
  4. $apiKey = "";
  5. $apiSecret ="";
  6.  
  7. // Create new phpFlickr object
  8.  
  9. $f = new phpFlickr($apiKey, $apiSecret);
  10.  
  11. $f->enableCache("db","mysql://<dbname>:<dbpass>@mysql.localhost/<dbname>");
  12. //$flickr->enableCache("fs", "/var/www/phpFlickrCache");
  13.  
  14. // Find the NSID of the username inputted via the form
  15. $nsid = $f->people_findByUsername($username);
  16.  
  17. function returnPhotosDetailView($f,$setid) {
  18.  
  19. $photosSetInfo = $f->photosets_getInfo($setid);
  20. $heading = "Photos: ".$photosSetInfo['title'];
  21. $photos = $f->photosets_getPhotos($setid, NULL, NULL);
  22. $i=0;
  23. $html .= "<ul id='photos-list' class='clearfix'>\n";
  24.  
  25.  
  26. foreach ($photos['photo'] as $photo) {
  27. $i++;
  28. if ($i % 6 == 0) {
  29. $html .="<li class='right'>\n";
  30. } else {
  31. $html .="<li>\n";
  32. }
  33.  
  34.  
  35. $html .= "<a href='".$f->buildPhotoURL($photo, "medium")."' rel='lightbox' class='vtip round shadow' title='&copy; All rights reserved'>";
  36.  
  37. $html .= "<img alt='$photo[title]' ".
  38. "src='".$f->buildPhotoURL($photo, "square")."' id='photo_".$photo['id']."' width='75' height='75' /></a>\n";
  39. $html .="</li>\n";
  40.  
  41. }
  42.  
  43. $html .="</ul>";
  44.  
  45. return $html;
  46.  
  47. echo $html;
  48.  
  49. }
  50.  
  51. $action = "detailview";
  52. $setid = "";
  53. $pid = rawurlencode($_GET['pid']);
  54.  
  55. $img_out = returnPhotosDetailView($f,$setid);
  56. $smarty->assign("img_out",$img_out);

Report this snippet  

You need to login to post a comment.