The service has functions to delete albums, photos, comments, and tags.
The service supports deleting an album for an authenticated user:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$albumQuery = new Zend_Gdata_Photos_AlbumQuery;
$albumQuery->setUser("sample.user");
$albumQuery->setAlbumId("1");
$albumQuery->setType('entry');
$entry = $service->getAlbumEntry($albumQuery);
$service->deleteAlbumEntry($entry, true);
The service supports deleting a photo for an authenticated user:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$photoQuery = new Zend_Gdata_Photos_PhotoQuery;
$photoQuery->setUser("sample.user");
$photoQuery->setAlbumId("1");
$photoQuery->setPhotoId("100");
$photoQuery->setType('entry');
$entry = $service->getPhotoEntry($photoQuery);
$service->deletePhotoEntry($entry, true);
The service supports deleting a comment for an authenticated user:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$photoQuery = new Zend_Gdata_Photos_PhotoQuery;
$photoQuery->setUser("sample.user");
$photoQuery->setAlbumId("1");
$photoQuery->setPhotoId("100");
$photoQuery->setType('entry');
$path = $photoQuery->getQueryUrl() . '/commentid/' . "1000";
$entry = $service->getCommentEntry($path);
$service->deleteCommentEntry($entry, true);
The service supports deleting a tag for an authenticated user:
<?php
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$service = new Zend_Gdata_Photos($client);
$photoQuery = new Zend_Gdata_Photos_PhotoQuery;
$photoQuery->setUser("sample.user");
$photoQuery->setAlbumId("1");
$photoQuery->setPhotoId("100");
$photoQuery->setKind("tag");
$query = $photoQuery->getQueryUrl();
$photoFeed = $service->getPhotoFeed($query);
foreach ($photoFeed as $entry) {
if ($entry instanceof Zend_Gdata_Photos_TagEntry) {
if ($entry->getContent() == $tagContent) {
$tagEntry = $entry;
}
}
}
$service->deleteTagEntry($tagEntry, true);
GData feeds, including those of the Picasa Web Albums service, implement optimistic concurrency, a versioning system that prevents users from overwriting changes, inadvertently. When deleting a entry through the service class, if the entry has been modified since it was last fetched, an exception will be thrown, unless explicitly set otherwise (in which case the deletion is retried on the updated entry).
An example of how to handle versioning during a deletion is shown by
deleteAlbumEntry():
<?php
// $album is the albumEntry to be deleted
try {
$this->delete($album);
} catch (Zend_Gdata_App_HttpException $e) {
if ($e->getMessage()->getStatus() === 409) {
$entry =
new Zend_Gdata_Photos_AlbumEntry($e->getMessage()->getBody());
$this->delete($entry->getLink('edit')->href);
} else {
throw $e;
}
}




