コード例 #1
0
ファイル: helper.php プロジェクト: sansandeep143/av
 public static function picasaweb_ListAlbums($userName, $key, $thumbsize = 666)
 {
     $url = 'http://picasaweb.google.com/data/feed/api/user/' . urlencode($userName) . '?authKey=' . $key . '&kind=album';
     $xml = file_get_contents($url);
     $xml = str_replace("xmlns='http://www.w3.org/2005/Atom'", '', $xml);
     $albums = array();
     $dom = new domdocument();
     $dom->loadXml($xml);
     $xpath = new domxpath($dom);
     $nodes = $xpath->query('//entry');
     foreach ($nodes as $node) {
         $imageUrl = $xpath->query('.//media:thumbnail/@url', $node)->item(0)->textContent;
         $imageUrl = str_replace('?imgmax=160', '?imgmax=' . $thumbsize, $imageUrl);
         $albumId = $xpath->query('.//gphoto:id', $node)->item(0)->textContent;
         $albumName = $xpath->query('.//gphoto:name', $node)->item(0)->textContent;
         $albumTitle = $xpath->query('.//media:title', $node)->item(0)->textContent;
         $imageCount = $xpath->query('.//gphoto:numphotos', $node)->item(0)->textContent;
         $published = $xpath->query('.//published', $node)->item(0)->textContent;
         $album = array();
         $album['folder'] = "{$userName}@{$albumId}";
         $album['name'] = $albumName;
         $album['description'] = $albumTitle;
         $album['image'] = $imageUrl;
         $album['date'] = $published;
         $album['overallCount'] = $imageCount;
         $album['url'] = 'http://picasaweb.google.com/' . urlencode($userName) . '/' . urlencode($album['name']);
         $albums[] = (object) $album;
         unset($album);
     }
     return $albums;
 }
コード例 #2
0
 protected function showAlbumContent($userId, $albumName)
 {
     $tmp = array();
     $url = 'http://picasaweb.google.com/data/feed/api/user/' . urlencode($userId) . '/album/' . $albumName . "/";
     $xml = $this->curlit($url);
     $xml = str_replace("xmlns='http://www.w3.org/2005/Atom'", '', $xml);
     if ($xml == "No album found.") {
         DB::alteration_message("{$albumName} NOT FOUND", "deleted");
         return $tmp;
     }
     $dom = new domdocument();
     if ($xml) {
         $dom->loadXml($xml);
         $xpath = new domxpath($dom);
         $nodes = $xpath->query('//entry');
         foreach ($nodes as $node) {
             $tmp[]['src'] = $xpath->query('.//media:thumbnail/@url', $node)->item(0)->textContent;
         }
     }
     return $tmp;
 }