3
如何獲取剛剛上傳的Youtube電影的視頻ID?如何獲取剛剛上傳的Youtube電影的視頻ID
我使用這個代碼:
$yt = new Zend_Gdata_YouTube($httpClient);
// create a new Zend_Gdata_YouTube_VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $yt->newMediaFileSource('mytestmovie.mov');
$filesource->setContentType('video/quicktime');
// set slug header
$filesource->setSlug('mytestmovie.mov');
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
$myVideoEntry->setVideoCategory('Comedy'); // Note that category must be a valid YouTube category !
// set keywords, please note that this must be a comma separated string
// and that each keyword cannot contain whitespace
$myVideoEntry->setVideoTags('cars, funny');
// upload URI for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
// try to upload the video, catching a Zend_Gdata_App_HttpException if available
// or just a regular Zend_Gdata_App_Exception
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
我認爲它馬上就的$newEntry
一個屬性,但我似乎無法找到它!
謝謝!
完美的答案!謝謝! – murze 2010-05-24 09:07:33
打電話給我啞巴,但我在將這段代碼集成到頁面時遇到問題。到底你如何實現這個? – Tom 2011-01-20 19:29:26
@Tom - 您需要首先實現您的上傳代碼,並確保將'$ newEntry'替換爲您存儲上傳返回的對象的任何位置。有關上傳代碼本身的更多信息,請參閱我的帖子中的鏈接。 – 2011-01-20 19:55:05