Advertisement
GuiEnrik

Album with Picasa API

Jan 2nd, 2012
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.16 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4.     <title>Álbum usando a API do Picasa + JQuery + FancyBox</title>
  5.     <link rel="stylesheet" type="text/css" href="http://fancybox.net/js/fancybox-1.3.4/jquery.fancybox-1.3.4.css" media="screen" />
  6.     <style type="text/css" media="all">
  7.         html, body {margin: 0px;    padding: 0px;}        
  8.         body {background: #EAEAEA; font-family: "Trebuchet MS",Verdana,Arial,sans-serif; font-size: 14px; line-height: 1.6;}        
  9.         a {outline: none; margin-right: 20px;}
  10.         a img {border: 1px solid #CCC; padding: 2px; margin: 10px 5px 10px 0;}
  11.     </style>
  12.  
  13.     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  14.  
  15.     <script type="text/javascript" src="http://fancybox.net/js/fancybox-1.3.4/jquery.fancybox-1.3.4.js"></script>
  16.     <script type="text/javascript" src="http://fancybox.net/js/fancybox-1.3.4/jquery.easing-1.3.pack.js"></script>
  17.     <script type="text/javascript">
  18.         $(document).ready(function() {
  19.             $("a.zoom").fancybox();
  20.         });
  21.     </script>
  22. </head>
  23. <body>
  24. <?php
  25.  /* Álbum usando API do Picasa... :D v. 0.1
  26.   *  
  27.   * Auhor: Felipe Furst
  28.   * email: felipe@ffurst.com
  29.   */  
  30.  
  31.     $picasaUser = "111990602259540535842"; // usuário do picasa
  32.  
  33.     /* ----------------- daqui só mexa se souber oq está fazendo ---------------- */
  34.  
  35.     if(!$_GET["id"]) {
  36.         $tt = file_get_contents("http://picasaweb.google.com/data/feed/api/user/{$picasaUser}"); // busca os álbuns
  37.         $xml = simplexml_load_string($tt);
  38.  
  39.         echo "<div id='albuns' align='center'>";
  40.  
  41.         for($i = 0; $i < count($xml->{"entry"}); $i++) {
  42.             $gphoto = $xml->{"entry"}[$i]->children("http://schemas.google.com/photos/2007"); // pega os nodos filhos do namespace http://schemas.google.com/photos/2007
  43.             $media = $xml->{"entry"}[$i]->children("http://search.yahoo.com/mrss/"); // semelhante à linha acima
  44.  
  45.             echo "<a href='".$_SERVER["PHP_SELF"]."?id=".$gphoto->{"id"}."'><img src='".$media->{"group"}->{"thumbnail"}->attributes()->url."' alt='' /></a>";
  46.         }
  47.  
  48.         echo "</div>";
  49.     }
  50.     else {
  51.         $tt = file_get_contents("http://picasaweb.google.com/data/feed/api/user/{$picasaUser}/albumid/".$_GET['id']); // busca as fotos de um determinado álbum passado por parâmetro
  52.         $xml = simplexml_load_string($tt);
  53.  
  54.         echo utf8_decode($xml->{"title"})."<br>".utf8_decode($xml->{"subtitle"})."<br>";
  55.         echo "<div id='album' align='center'>";
  56.  
  57.         for($i = 0; $i < count($xml->{"entry"}); $i++) {
  58.             $media = $xml->{"entry"}[$i]->children("http://search.yahoo.com/mrss/"); // esse cara aqui vc já conhece ...
  59.  
  60.             echo "<a class='zoom' rel='group' title='".utf8_decode($media->{"group"}->{"description"})."' href='".$media->{"group"}->{"content"}->attributes()->url."'><img src='".$media->{"group"}->{"thumbnail"}[1]->attributes()->url."' alt='' /></a>";
  61.         }
  62.  
  63.         echo "</div>";
  64.     }
  65. ?>
  66.  
  67. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement