ה API הבא משמש להעלאת קבצי וידאו ל יוטיוב דרך ממשק המשתמש בקטע קוד PHP המוטמע באתר שלכם , לצורך שימוש ב API הבא יש צורך בשם משתמש ו API KEY מגוגל למימוש הקוד , יש צורך בשימוש ב ZendFrameword , עוד על דרישות המינימום לחצו כאן. , לדוגמא עובדת במימוש YouTube Uploader API
$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‘);
// optionally set some developer tags (see Searching by Developer Tags for more details)
$myVideoEntry->setVideoDeveloperTags(array(‘mydevelopertag‘, ‘anotherdevelopertag‘));
// 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 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();
}
דוגמא למימוש ה API