2010-12-01 85 views
0

我想使用API​​更新Picasa網絡相冊中我的視頻的縮略圖。 我的Photos PHP sample code正在運行Photos數據API。使用Zend GData Picasa API更新Picasa視頻縮略圖

該文件說,我可以通過更新照片「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);   
} 

回答

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' 全代碼和工作的例子。