Пример #1
0
 /**
  * Delete a TagEntry.
  *
  * @param Zend_Gdata_Photos_TagEntry $tag The tag entry to
  *          delete.
  * @param boolean $catch Whether to catch an exception when
  *            modified and re-delete or throw
  * @return void.
  * @throws Zend_Gdata_App_Exception
  * @throws Zend_Gdata_App_HttpException
  */
 public function deleteTagEntry($tag, $catch)
 {
     if ($catch) {
         try {
             $this->delete($tag);
         } catch (Zend_Gdata_App_HttpException $e) {
             if ($e->getResponse()->getStatus() === 409) {
                 $entry = new Zend_Gdata_Photos_TagEntry($e->getResponse()->getBody());
                 $this->delete($entry->getLink('edit')->href);
             } else {
                 throw $e;
             }
         }
     } else {
         $this->delete($tag);
     }
 }
Пример #2
0
/**
 * Adds a new tag to the specified photo
 *
 * @param  Zend_Http_Client $client The authenticated client
 * @param  string           $user   The user's account name
 * @param  integer          $album  The album's id
 * @param  integer          $photo  The photo's id
 * @param  string           $tag    The tag to add to the photo
 * @return void
 */
function addTag($client, $user, $album, $photo, $tag)
{
    $photos = new Zend_Gdata_Photos($client);
    $entry = new Zend_Gdata_Photos_TagEntry();
    $entry->setTitle($photos->newTitle($tag));
    $photoQuery = new Zend_Gdata_Photos_PhotoQuery();
    $photoQuery->setUser($user);
    $photoQuery->setAlbumId($album);
    $photoQuery->setPhotoId($photo);
    $photoQuery->setType('entry');
    $photoEntry = $photos->getPhotoEntry($photoQuery);
    $result = $photos->insertTagEntry($entry, $photoEntry);
    if ($result) {
        outputPhotoFeed($client, $user, $album, $photo);
    } else {
        echo "There was an issue with the tag creation.";
    }
}
 public function createTag($photo)
 {
     $client = $this->photos;
     $tag = new Zend_Gdata_Photos_TagEntry();
     $tag->setTitle($client->newTitle("test tag"));
     $tag->setContent($client->newContent("test tag"));
     $tag->setCategory(array($client->newCategory('http://schemas.google.com/photos/2007#tag', 'http://schemas.google.com/g/2005#kind')));
     $newTag = $client->insertTagEntry($tag, $photo);
     $this->assertEquals($tag->getTitle(), $newTag->getTitle());
     $this->assertEquals($newTag->getTitle(), $client->getTagEntry($newTag->getLink('self')->href)->getTitle());
     return $newTag;
 }