Josh
Josh

Reputation: 6322

Updating Picasa Video Thumbnails Using Zend GData Picasa API

I want to update the thumbnail of my video in picasa web albums using the API. I've got the Photos PHP sample code for the Photos data API running.

The documentation says that I can "Provide your own video thumbnail" by updating the photo.

I've tried the following function but nothing happens. Please help!

/**
 * Updates photo (for changing video thumbs
 *
 * @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  array            $photo   The uploaded photo
 * @return void
 */
function updatePhoto($client, $user, $albumId, $photoId, $photo)
{
        $photos = new Zend_Gdata_Photos($client);

        $photoQuery = new Zend_Gdata_Photos_PhotoQuery;
        $photoQuery->setUser($user);
        $photoQuery->setAlbumId($albumId);
        $photoQuery->setPhotoId($photoId);
        $photoQuery->setType('entry');

        $entry = $photos->getPhotoEntry($photoQuery);

        $fd = $photos->newMediaFileSource($photo["tmp_name"]);
        $fd->setContentType($photo["type"]);
        $entry->setMediaSource($fd);

        $entry->save();

        outputPhotoFeed($client, $user, $albumId, $photoId);        
}

Upvotes: 0

Views: 988

Answers (1)

Josh
Josh

Reputation: 6322

i was nearly right, updated code that works...

    /**
     * Updates photo (for changing video thumbs
     *
     * @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  array            $photo   The uploaded photo
     * @return void
     */
    function updatePhoto($client, $user, $albumId, $photoId, $photo)
    {
            $photos = new Zend_Gdata_Photos($client);

            $photoQuery = new Zend_Gdata_Photos_PhotoQuery;
            $photoQuery->setUser($user);
            $photoQuery->setAlbumId($albumId);
            $photoQuery->setPhotoId($photoId);
            $photoQuery->setType('entry');

            $entry = $photos->getPhotoEntry($photoQuery);
            $uri = $entry->getLink("edit-media")->href;             

            $fd = $photos->newMediaFileSource($photo["tmp_name"]);
            $fd->setContentType($photo["type"]);
            $entry->setMediaSource($fd);

        $result = $entry->save($uri);
            if ($result) {
                outputPhotoFeed($client, $user, $albumId, $photoId);        
            } else {
                echo "There was an issue with upating this photo.";
            }
    }

See 'Updating Thumbnails of Picasa Web Videos' for full code and working example.

Upvotes: 1

Related Questions