/**
  * Delete a CommentEntry.
  *
  * @param Zend_Gdata_Photos_CommentEntry $comment The comment 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 deleteCommentEntry($comment, $catch)
 {
     if ($catch) {
         try {
             $this->delete($comment);
         } catch (Zend_Gdata_App_HttpException $e) {
             if ($e->getResponse()->getStatus() === 409) {
                 $entry = new Zend_Gdata_Photos_CommentEntry($e->getResponse()->getBody());
                 $this->delete($entry->getLink('edit')->href);
             } else {
                 throw $e;
             }
         }
     } else {
         $this->delete($comment);
     }
 }
Exemple #2
0
/**
 * Adds a new comment to the specified photo
 *
 * @param  Zend_Http_Client $client  The authenticated client
 * @param  string           $user    The user's account name
 * @param  integer          $albumId The album's id
 * @param  integer          $photoId The photo's id
 * @param  string           $comment The comment to add
 * @return void
 */
function addComment($client, $user, $album, $photo, $comment)
{
    $photos = new Zend_Gdata_Photos($client);
    $entry = new Zend_Gdata_Photos_CommentEntry();
    $entry->setTitle($photos->newTitle($comment));
    $entry->setContent($photos->newContent($comment));
    $photoQuery = new Zend_Gdata_Photos_PhotoQuery();
    $photoQuery->setUser($user);
    $photoQuery->setAlbumId($album);
    $photoQuery->setPhotoId($photo);
    $photoQuery->setType('entry');
    $photoEntry = $photos->getPhotoEntry($photoQuery);
    $result = $photos->insertCommentEntry($entry, $photoEntry);
    if ($result) {
        outputPhotoFeed($client, $user, $album, $photo);
    } else {
        echo "There was an issue with the comment creation.";
    }
}
 public function createComment($photo)
 {
     $client = $this->photos;
     $comment = new Zend_Gdata_Photos_CommentEntry();
     $comment->setTitle($client->newTitle("test comment"));
     $comment->setContent($client->newContent("test comment"));
     $comment->setCategory(array($client->newCategory('http://schemas.google.com/photos/2007#comment', 'http://schemas.google.com/g/2005#kind')));
     $newComment = $client->insertCommentEntry($comment, $photo);
     $this->assertEquals($comment->getContent(), $newComment->getContent());
     $this->assertEquals($newComment->getContent(), $client->getCommentEntry($newComment->getLink('self')->href)->getContent());
     return $newComment;
 }