使用 Zend GData Picasa API 更新 Picasa 视频缩略图

发布于 2024-10-05 10:06:56 字数 1416 浏览 0 评论 0原文

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

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

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

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硪扪都還晓 2024-10-12 10:06:56

我几乎是对的,更新后的代码可以工作...

    /**
     * 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 网络视频的缩略图'以获取完整代码和工作示例。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文