The service has functions to retrieve a feed, or individual entries, for users, albums, and individual photos.
The service supports retrieving a user feed and list of the user's content. If the requested user is also the authenticated user, entries marked as "hidden" will also be returned.
The user feed can be accessed by passing the username to the
getUserFeed() method:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
try {
$userFeed = $service->getUserFeed("sample.user");
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
Or, the feed can be accessed by constructing a query, first:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$query = new Zend_Gdata_Photos_UserQuery();
$query->setUser("sample.user");
try {
$userFeed = $service->getUserFeed(null, $query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
Constructing a query also provides the ability to request a user entry object:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$query = new Zend_Gdata_Photos_UserQuery();
$query->setUser("sample.user");
$query->setType("entry");
try {
$userEntry = $service->getUserEntry($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
The service supports retrieving an album feed and a list of the album's content.
The album feed is accessed by constructing a query object and passing it to
getAlbumFeed():
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$query = new Zend_Gdata_Photos_AlbumQuery();
$query->setUser("sample.user");
$query->setAlbumId("1");
try {
$albumFeed = $service->getAlbumFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
Alternatively, the query object can be given an album name with
setAlbumName(). Setting the album name is mutually
exclusive with setting the album id, and setting one will unset the other.
Constructing a query also provides the ability to request an album entry object:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$query = new Zend_Gdata_Photos_AlbumQuery();
$query->setUser("sample.user");
$query->setAlbumId("1");
$query->setType("entry");
try {
$albumEntry = $service->getAlbumEntry($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
The service supports retrieving a photo feed and a list of associated comments and tags.
The photo feed is accessed by constructing a query object and passing it to
getPhotoFeed():
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$query = new Zend_Gdata_Photos_PhotoQuery();
$query->setUser("sample.user");
$query->setAlbumId("1");
$query->setPhotoId("100");
try {
$photoFeed = $service->getPhotoFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
Constructing a query also provides the ability to request a photo entry object:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$query = new Zend_Gdata_Photos_PhotoQuery();
$query->setUser("sample.user");
$query->setAlbumId("1");
$query->setPhotoId("100");
$query->setType("entry");
try {
$photoEntry = $service->getPhotoEntry($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
The service supports retrieving comments from a feed of a different type. By setting a query to return a kind of "comment", a feed request can return comments associated with a specific user, album, or photo.
Performing an action on each of the comments on a given photo can be accomplished as follows:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$query = new Zend_Gdata_Photos_PhotoQuery();
$query->setUser("sample.user");
$query->setAlbumId("1");
$query->setPhotoId("100");
$query->setKind("comment");
try {
$photoFeed = $service->getPhotoFeed($query);
foreach ($photoFeed as $entry) {
if ($entry instanceof Zend_Gdata_Photos_CommentEntry) {
// Do something with the comment
}
}
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
The service supports retrieving tags from a feed of a different type. By setting a query to return a kind of "tag", a feed request can return tags associated with a specific photo.
Performing an action on each of the tags on a given photo can be accomplished as follows:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$query = new Zend_Gdata_Photos_PhotoQuery();
$query->setUser("sample.user");
$query->setAlbumId("1");
$query->setPhotoId("100");
$query->setKind("tag");
try {
$photoFeed = $service->getPhotoFeed($query);
foreach ($photoFeed as $entry) {
if ($entry instanceof Zend_Gdata_Photos_TagEntry) {
// Do something with the tag
}
}
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}




