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:
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.
<?php require_once 'Zend/Loader.php'; // the Zend dir must be in your Zend_Loader::loadClass('Zend_Gdata_YouTube'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_App_Exception'); $authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin'; $userName = '---------'; $password = '------'; $service = 'youtube'; $client = null; $source = 'http://localhost/www/redbook/btube/new/upload.php'; // a short string $loginToken = null; $loginCaptcha = null; $developerKey = '--------'; $applicationId = 'relay'; $clientId = '-------'; try { $client = Zend_Gdata_ClientLogin::getHttpClient($userName, $password, $service); } catch(Zend_Gdata_App_Exception $ex) { // Report the exception to the user } try { $yt = new Zend_Gdata_YouTube($client, $applicationId, $clientId, $developerKey); } catch(Zend_Gdata_App_Exception $ex) { // Report the exception to the user } try { $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); } catch(Zend_Gdata_App_Exception $ex) { // Report the exception to the user } // create a new Zend_Gdata_App_MediaFileSource object $filesource = $yt->newMediaFileSource('file:///home/krystian/Pulpit/sdsd.wav'); $filesource->setContentType('video/quicktime'); // set slug header $filesource->setSlug('test.oga'); // add the filesource to the video entry $myVideoEntry->setMediaSource($filesource); $myVideoEntry->setVideoTitle('My Test Movie Ubuntu'); $myVideoEntry->setVideoDescription('My Test Movie'); $myVideoEntry->setVideoCategory('Games'); // Note that category must // set keywords, please note that this must be a comma separated // and that each keyword cannot contain whitespace $myVideoEntry->setVideoTags('mmorpg, gry, online'); // optionally set some developer tags (see Searching by Developer Tags // optionally set the video's location $yt->registerPackage('Zend_Gdata_Geo'); $yt->registerPackage('Zend_Gdata_Geo_Extension'); $where = $yt->newGeoRssWhere(); $position = $yt->newGmlPos('37.0 -122.0'); $where->point = $yt->newGmlPoint($position); $myVideoEntry->setWhere($where); // upload URI for the currently authenticated user $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads'; // try to upload the video, catching a Zend_Gdata_App_HttpException if // or just a regular Zend_Gdata_App_Exception try { $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry'); } catch(Zend_Gdata_App_Exception $ex) { // Report the exception to the user } ?>
Dokumentacja YouTube API: link.
Bardzo proszę o pomoc.