在我使用 PHP YouTube API 上传视频后,此错误“失败(无法转换视频文件)”显示在视频管理器中。
我正在使用 PHP API 文档中的示例。其他人使用相同的代码并且它适用于他们,这个代码有什么问题?
<?php
require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$authenticationURL = 'https://www.google.com/accounts/ClientLogin';
//filtrunet
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
$username = 'username',
$password = 'password',
$service = 'youtube',
$client = null,
$source = 'source',
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);
$devkey = 'devkey';
$yt = new Zend_Gdata_YouTube($httpClient, '', '', $devkey);
// Note that this example creates an unversioned service object.
// You do not need to specify a version number to upload content
// since the upload behavior is the same for all API versions.
$yt = new Zend_Gdata_YouTube($httpClient);
// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setVideoPrivate();
// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $yt->newMediaFileSource('video.mov');
$filesource->setContentType('video/quicktime');
// set slug header
$filesource->setSlug('video.mov');
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle('My Test video');
$myVideoEntry->setVideoDescription('My Test video');
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('Autos');
// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');
// set some developer tags -- this is optional
// (see Searching by Developer Tags for more details)
$myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag'));
// set the video's location -- this is also optional
$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/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 otherwise
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl,
'Zend_Gdata_YouTube_VideoEntry');
$id = $newEntry->getVideoId(); // YOUR ANSWER IS HERE :)
echo $id;
}
catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
?>
谢谢