Cześć!

Już od dwóch dni próbuję zrobić prosty upload w YouTube API. Chciałbym wysłać plik i dostać jego id, aby móc później nim "obracać". Znalazłem na google groups kod:
  1. <?php
  2. ini_set("memory_limit","1024M");
  3.  
  4. require_once 'Zend/Loader.php'; // the Zend dir must be in your
  5.  
  6. Zend_Loader::loadClass('Zend_Gdata_YouTube');
  7. Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
  8. Zend_Loader::loadClass('Zend_Gdata_App_Exception');
  9.  
  10. $authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin';
  11. $userName = '---------';
  12. $password = '------';
  13. $service = 'youtube';
  14. $client = null;
  15. $source = 'http://localhost/www/redbook/btube/new/upload.php'; // a short string
  16.  
  17. $loginToken = null;
  18. $loginCaptcha = null;
  19. $developerKey = '--------';
  20. $applicationId = 'relay';
  21. $clientId = '-------';
  22.  
  23. try {
  24.        $client = Zend_Gdata_ClientLogin::getHttpClient($userName, $password, $service);
  25. } catch(Zend_Gdata_App_Exception $ex) {
  26.    // Report the exception to the user
  27.    die($ex->getMessage());
  28. }
  29.  
  30. try {
  31.        $yt = new Zend_Gdata_YouTube($client, $applicationId, $clientId, $developerKey);
  32. } catch(Zend_Gdata_App_Exception $ex) {
  33.    // Report the exception to the user
  34.    die($ex->getMessage());
  35. }
  36.  
  37. try {
  38.        $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
  39. } catch(Zend_Gdata_App_Exception $ex) {
  40.  
  41.    // Report the exception to the user
  42.    die($ex->getMessage());
  43. }
  44.  
  45.  
  46. // create a new Zend_Gdata_App_MediaFileSource object
  47. $filesource = $yt->newMediaFileSource('file:///home/krystian/Pulpit/sdsd.wav');
  48. $filesource->setContentType('video/quicktime');
  49. // set slug header
  50. $filesource->setSlug('test.oga');
  51.  
  52. // add the filesource to the video entry
  53. $myVideoEntry->setMediaSource($filesource);
  54.  
  55. $myVideoEntry->setVideoTitle('My Test Movie Ubuntu');
  56. $myVideoEntry->setVideoDescription('My Test Movie');
  57. $myVideoEntry->setVideoCategory('Games'); // Note that category must
  58.  
  59. // set keywords, please note that this must be a comma separated
  60.  
  61. // and that each keyword cannot contain whitespace
  62. $myVideoEntry->setVideoTags('mmorpg, gry, online');
  63.  
  64. // optionally set some developer tags (see Searching by Developer Tags
  65.  
  66. $myVideoEntry->setVideoDeveloperTags(array('mydevelopertag', 'anotherdevelopertag'));
  67.  
  68.  
  69.  
  70.  
  71.  
  72. // optionally set the video's location
  73. $yt->registerPackage('Zend_Gdata_Geo');
  74. $yt->registerPackage('Zend_Gdata_Geo_Extension');
  75. $where = $yt->newGeoRssWhere();
  76. $position = $yt->newGmlPos('37.0 -122.0');
  77. $where->point = $yt->newGmlPoint($position);
  78. $myVideoEntry->setWhere($where);
  79.  
  80. // upload URI for the currently authenticated user
  81. $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
  82.  
  83. // try to upload the video, catching a Zend_Gdata_App_HttpException if
  84. // or just a regular Zend_Gdata_App_Exception
  85.  
  86.  
  87. try {
  88.        $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
  89. } catch(Zend_Gdata_App_Exception $ex) {
  90.    // Report the exception to the user
  91.    die($ex->getMessage());
  92. }
  93. ?>
Problem jest z tym, że kod jedynie wysyła plik, a nie wyświetla już jego id. Męczę się i męczę i nic z tego nie wychodzi. Nie znam zend-a i prawie większość kodu w cale nie rozumiem.

Dokumentacja YouTube API: link.


Bardzo proszę o pomoc.