PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Deleting Entries

The service has functions to delete albums, photos, comments, and tags.

Deleting An Album

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($entrytrue);

Deleting A Photo

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($entrytrue);

Deleting A Comment

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($entrytrue);

Deleting A Tag

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($tagEntrytrue);

Optimistic Concurrency (Notes On Deletion)

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;
    }
}

Zend Framework