Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* POSTED AT TECHNOSLAB.BLOGSPOT.COM */
- /* DOWNLOAD REQUIRED LIBRARIES : http://framework.zend.com/download/gdata */
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass('Zend_Gdata_YouTube');
- Zend_Loader::loadClass('Zend_Gdata_AuthSub');
- Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
- $yt = new Zend_Gdata_YouTube();
- $authenticationURL= 'https://www.google.com/accounts/ClientLogin';
- /* AUTH :: ENTER YOUR USERNAME / PASSWORD */
- $user = "YOUTUBE_COM_USER";
- $pass = "YOUTUBE_COM_PASS";
- /* API :: GET THEM FROM http://code.google.com/apis/youtube/dashboard/gwt/index.html */
- $apiKEY = "YOUR_API_KEY";
- $apiNAME = "YOUR_API_NAME";
- $video_path = "sample.mov"; // WITH PROPER PATH
- $video_type = "video/quicktime"; // VIDEO TYPE : http://www.w3schools.com/media/media_mimeref.asp
- $video_title = "Sample video upload"; // TITLE FOR VIDEO
- $video_description = "Blah blah blah... Checking upload.."; // DESCRIPTION
- $httpClient = Zend_Gdata_ClientLogin::getHttpClient(
- $username = $user,
- $password = $pass,
- $service = 'youtube',
- $client = null,
- $source = $apiNAME,
- $loginToken = null,
- $loginCaptcha = null,
- $authenticationURL
- );
- $yt = new Zend_Gdata_YouTube($httpClient,'','',$apiKEY);
- $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
- $filesource = $yt->newMediaFileSource($video_path);
- $filesource->setContentType($video_type);
- $filesource->setSlug('file.mov');
- $myVideoEntry->setMediaSource($filesource);
- $myVideoEntry->setVideoTitle($video_title);
- $myVideoEntry->setVideoDescription($video_description);
- $myVideoEntry->setVideoCategory('Autos');
- $myVideoEntry->SetVideoTags('cars, funny');
- $myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag'));
- $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);
- $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
- 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();
- }
- echo "UPLOAD SUCCESSFULLY";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment