【问题标题】:Updating Picasa Video Thumbnails Using Zend GData Picasa API使用 Zend GData Picasa API 更新 Picasa 视频缩略图
【发布时间】:2011-05-18 15:53:00
【问题描述】:

我想使用 API 更新我在 picasa 网络相册中的视频缩略图。 我有 Photos PHP sample code 用于运行照片数据 API。

文档说我可以通过更新照片“Provide your own video thumbnail”。

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

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

【问题讨论】:

    标签: php api picasa zend-gdata


    【解决方案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.";
                }
        }
    

    有关完整代码和工作示例,请参阅“Updating Thumbnails of Picasa Web Videos”。

    【讨论】:

      猜你喜欢
      • 2013-04-04
      • 2015-08-09
      • 1970-01-01
      • 2013-07-19
      • 1970-01-01
      • 2011-04-22
      • 2011-10-08
      • 1970-01-01
      • 2012-11-10
      相关资源
      最近更新 更多