2010-12-01 39 views
0

Je souhaite mettre à jour la miniature de ma vidéo dans des albums Web Picasa à l'aide de l'API. J'ai l'Photos PHP sample code pour l'API de données Photos en cours d'exécution.Mise à jour des miniatures vidéo Picasa à l'aide de l'API Zend GData Picasa

La documentation dit que je peux "Provide your own video thumbnail" en mettant à jour la photo.

J'ai essayé la fonction suivante mais rien ne se passe. S'il vous plaît aider!

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

Répondre

1

i était presque droite, le code mis à jour qui fonctionne ...

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

Voir 'Updating Thumbnails of Picasa Web Videos' pour le code complet et un exemple de travail.