3
我使用Youtube API上傳一些視頻,但我無法弄清楚如何將上傳的視頻添加到特定的播放列表。我已經搜遍了谷歌,我根本沒有找到任何幫助。Youtube API(PHP) - 如何將(現有)視頻添加到現有播放列表?
我已閱讀開發人員指南,我發現這個 - https://developers.google.com/youtube/2.0/developers_guide_php#Adding_a_Playlist_Video,但我不知道如何定義哪個視頻是哪個現有播放列表,我希望腳本添加。
這是我現在用上傳視頻:
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$developerKey = 'MYDEVKEY';
$applicationId = 'SOMEID';
$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
$username = 'user',
$password = 'pass',
$service = 'youtube',
$client = null,
$source = 'something',
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);
$clientId = 'something';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$videoName = "video/user_12345.mov";
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = $yt->newMediaFileSource($videoName);
$filesource->setContentType('video/quicktime');
$filesource->setSlug('video/test.mov');
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle('Video title');
$myVideoEntry->setVideoDescription('Video description');
$myVideoEntry->setVideoCategory('Autos');
$myVideoEntry->SetVideoTags('car');
$uploadUrl ='https://uploads.gdata.youtube.com/feeds/users/default/uploads';
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
$state = $newEntry->getVideoState();
$idv = $newEntry->getVideoId();
我沒有使用YT-API的ZEND Framework包裝器的經驗,但[this](https://developers.google.com/youtube/2.0/developers_guide_protocol_playlists#Adding_a_video_to_a_playlist)鏈接顯示您需要什麼類型的請求。您可以使用PHP cURL來發出請求。 – user1190992