0

我想使用 API 更新我在 picasa 网络相册中的视频缩略图。我已经为照片数据 API 运行了照片 PHP 示例代码

文档说我可以通过更新照片“提供您自己的视频缩略图”。

我尝试了以下功能,但没有任何反应。请帮忙!

/**
 * 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);        
}
4

1 回答 1

1

我几乎是对的,更新的代码有效......

    /**
     * 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.";
            }
    }

有关完整代码和工作示例,请参阅“更新 Picasa 网络视频的缩略图”。

于 2010-12-02T12:58:49.523 回答