function getFoto($user, $pass, $albumName, $photoId) { $service = Zend_Gdata_Photos::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); $photos = new Zend_Gdata_Photos($client); $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setUser($user); $query->setAlbumName($albumName); $query->setPhotoId($photoId); $query = $query->getQueryUrl(); $photoFeed = $photos->getPhotoFeed($query); $thumbs = $photoFeed->getMediaGroup()->getContent(); return $thumbs[0]->getUrl(); }
/** * Outputs the feed of the specified photo * * @param Zend_Http_Client $client The authenticated client object * @param string $user The user's account name * @param integer $albumId The album's id * @param integer $photoId The photo's id * @return void */ function outputPhotoFeed($client, $user, $albumId, $photoId) { $photos = new Zend_Gdata_Photos($client); $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setUser($user); $query->setAlbumId($albumId); $query->setPhotoId($photoId); $query = $query->getQueryUrl() . "?kind=comment,tag"; $photoFeed = $photos->getPhotoFeed($query); echo "<h2>Photo Feed for: " . $photoFeed->getTitle() . "</h2>"; $thumbs = $photoFeed->getMediaGroup()->getThumbnail(); echo "<img src='" . $thumbs[2]->url . "' />"; echo "<h3 class='nopad'>Comments:</h3>"; echo "<ul>\n"; foreach ($photoFeed as $entry) { if ($entry instanceof Zend_Gdata_Photos_CommentEntry) { echo "\t<li>" . $entry->getContent(); echo "<form action='" . getCurrentScript() . "' method='post' class='deleteForm'>"; echo "<input type='hidden' name='user' value='" . $user . "' />"; echo "<input type='hidden' name='album' value='" . $albumId . "' />"; echo "<input type='hidden' name='photo' value='" . $photoId . "' />"; echo "<input type='hidden' name='comment' value='" . $entry->getGphotoId(); echo "' />"; echo "<input type='hidden' name='command' value='deleteComment' />"; echo "<input type='submit' value='Delete' /></form>"; echo "</li>\n"; } } echo "</ul>\n"; echo "<h4>Add a Comment</h4>"; ?> <form method="POST" action="<?php echo getCurrentScript(); ?> "> <input type="hidden" name="command" value="addComment" /> <input type="hidden" name="user" value="<?php echo $user; ?> " /> <input type="hidden" name="album" value="<?php echo $albumId; ?> " /> <input type="hidden" name="photo" value="<?php echo $photoId; ?> " /> <input type="text" name="comment" /> <input type="submit" name="Comment" value="Comment" /> </form> <?php echo "<br />"; echo "<h3 class='nopad'>Tags:</h3>"; echo "<ul>\n"; foreach ($photoFeed as $entry) { if ($entry instanceof Zend_Gdata_Photos_TagEntry) { echo "\t<li>" . $entry->getTitle(); echo "<form action='" . getCurrentScript() . "' method='post' class='deleteForm'>"; echo "<input type='hidden' name='user' value='" . $user . "' />"; echo "<input type='hidden' name='album' value='" . $albumId . "' />"; echo "<input type='hidden' name='photo' value='" . $photoId . "' />"; echo "<input type='hidden' name='tag' value='" . $entry->getContent(); echo "' />"; echo "<input type='hidden' name='command' value='deleteTag' />"; echo "<input type='submit' value='Delete' /></form>"; echo "</li>\n"; } } echo "</ul>\n"; echo "<h4>Add a Tag</h4>"; ?> <form method="POST" action="<?php echo getCurrentScript(); ?> "> <input type="hidden" name="command" value="addTag" /> <input type="hidden" name="user" value="<?php echo $user; ?> " /> <input type="hidden" name="album" value="<?php echo $albumId; ?> " /> <input type="hidden" name="photo" value="<?php echo $photoId; ?> " /> <input type="text" name="tag" /> <input type="submit" name="Tag" value="Tag" /> </form> <?php displayBackLink(); }
/** * Check the consistency of a user feed request for private data */ public function testPrivatePhotoQuery() { $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user/albumid/1/photoid/1?access=private"; $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setUser("sample.user"); $query->setAlbumId("1"); $query->setPhotoId("1"); $query->setAccess("private"); $generatedString = $query->getQueryUrl(); // Assert that the generated query matches the correct one $this->assertEquals($queryString, $generatedString); }
function _deletePhoto($id, $album) { $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setPhotoId($id); $query->setAlbumId($album); $photo = $this->_service->getPhotoEntry($query); $this->_service->deletePhotoEntry($photo); return true; }
/** * Retrieve list of gallery images and their properties * * @access public * @param string $gallery * @throws Exception * @return array $photoAttrs */ public function getGalleryImages($gallery) { $query = new Zend_Gdata_Photos_AlbumQuery(); $query->setUser($this->getUser()); $query->setStartIndex(self::START_INDEX); $query->setMaxResults(self::MAX_RESULTS); if (Zend_Validate::is($gallery, 'Alnum')) { $query->setAlbumName($gallery); } elseif (Zend_Validate::is($gallery, 'Digits')) { $query->setAlbumId($gallery); } else { throw new Exception("Invalid gallery was given"); } try { $albumFeed = $this->getGphotoService()->getAlbumFeed($query); /* $previousLink = $albumFeed->getLink("previous"); $nextLink = $albumFeed->getLink("next"); if (!is_null($previousLink)) { $previousFeed = $this->getGphotoService()->getAlbumFeed($previousLink->href); $this->setPreviousLink($previousLink->href); } if (!is_null($nextLink)) { $nextFeed = $this->getGphotoService()->getAlbumFeed($nextLink->href); $this->setNextLink($nextLink->href); } */ $this->setGGalleryNumPhotos($albumFeed->getGphotoNumPhotos()); $this->setGGalleryLocation($albumFeed->getGphotoLocation()); $this->setGGalleryTimestamp(substr($albumFeed->getGphotoTimestamp(), 0, 10)); $this->setGGalleryTitle($albumFeed->title); foreach ($albumFeed as $photo) { $photoQuery = new Zend_Gdata_Photos_PhotoQuery(); $photoQuery->setUser($this->getUser()); if (Zend_Validate::is($gallery, 'Alnum')) { $photoQuery->setAlbumName($gallery); } elseif (Zend_Validate::is($gallery, 'Digits')) { $photoQuery->setAlbumId($gallery); } else { throw new Exception("Invalid gallery was given"); } $photoQuery->setPhotoId($photo->getGphotoId()); $photoQuery->setImgMax(self::PIXEL_MAX); $photoFeed = $this->getGphotoService()->getPhotoFeed($photoQuery); $geoRssWhere = empty($photo->getGeoRssWhere()->point->pos->text) ? "" : $photo->getGeoRssWhere()->point->pos->text; $gPicasa = new CW_Google_Picasa_Photo($photo->getGphotoId(), $photo->getGphotoCommentCount(), $photo->getGphotoCommentingEnabled(), $photoFeed->getGphotoSize(), $photoFeed->getGphotoTimestamp(), $photoFeed->mediaGroup->content[0]->url, $photoFeed->mediaGroup->description->text, $photoFeed->mediaGroup->thumbnail[0]->url, $photoFeed->mediaGroup->thumbnail[0]->width, $photoFeed->mediaGroup->thumbnail[0]->height, $geoRssWhere); $this->setPhotoAttrs($gPicasa); } } catch (Zend_Gdata_App_Exception $e) { print "Error: " . $e->__toString(); } catch (Zend_Gdata_App_HttpException $httpexception) { print $httpexception->getResponse()->getBody(); } catch (Exception $e) { print "Error: " . $e->__toString(); } return $this->getPhotoAttrs(); }
public function deletePic($idAlbum, $picId) { static::auth(); $photoQuery = new Zend_Gdata_Photos_PhotoQuery(); $photoQuery->setUser("default"); $photoQuery->setAlbumId($idAlbum); $photoQuery->setPhotoId($picId); $photoQuery->setType('entry'); try { $entry = static::$service->getPhotoEntry($photoQuery); static::$service->deletePhotoEntry($entry, true); static::$status['error'] = false; static::$status['message'] = "Success !"; } catch (Zend_Gdata_App_Exception $e) { static::$status['message'] = $e->getMessage(); } return static::$status; }
/** * Obtener una foto especifica. * * @param integer $albumId id del album * @param integer $photoId id de la foto * @return Zend_Gdata_Photos_PhotoEntry */ public function getPhoto($albumId, $photoId) { $photoQuery = new Zend_Gdata_Photos_PhotoQuery(); $photoQuery->setAlbumId($albumId); $photoQuery->setPhotoId($photoId); $photoQuery->setType('entry'); $entry = $this->_photos->getPhotoEntry($photoQuery); return $entry; }