Created
December 23, 2010 15:30
-
-
Save vitorpacheco/753120 to your computer and use it in GitHub Desktop.
script para teste de upload de videos para o youtube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = '/var/www/zend/library'; | |
set_include_path(get_include_path() . PATH_SEPARATOR . $path); | |
require_once 'Zend/Loader.php'; | |
Zend_Loader::loadClass('Zend_Gdata_YouTube'); | |
Zend_Loader::loadClass('Zend_Gdata_AuthSub'); | |
Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); | |
$email = '[email protected]'; | |
$senha = 'xxxxxx'; | |
$authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin'; | |
$httpClient = Zend_Gdata_ClientLogin::getHttpClient( | |
$email, | |
$senha, | |
'youtube', | |
null, | |
'MySource', | |
null, | |
null, | |
$authenticationURL | |
); | |
$yt = new Zend_Gdata_YouTube($httpClient); | |
// create a new Zend_Gdata_YouTube_VideoEntry object | |
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); | |
// set up media group as in the example above | |
$mediaGroup = $yt->newMediaGroup(); | |
$mediaGroup->title = $yt->newMediaTitle()->setText('My Test Movie'); | |
$mediaGroup->description = $yt->newMediaDescription()->setText('My description'); | |
// note the different schemes for categories and developer tags | |
$categoryScheme = 'http://gdata.youtube.com/schemas/2007/categories.cat'; | |
$developerTagScheme = 'http://gdata.youtube.com/schemas/2007/developertags.cat'; | |
$mediaGroup->category = array( | |
$yt->newMediaCategory()->setText('Autos')->setScheme($categoryScheme), | |
$yt->newMediaCategory()->setText('mydevelopertag')->setScheme($developerTagScheme), | |
$yt->newMediaCategory()->setText('anotherdevelopertag')->setScheme($developerTagScheme), | |
); | |
$mediaGroup->keywords = $yt->newMediaKeywords()->setText('cars, funny'); | |
$myVideoEntry->mediaGroup = $mediaGroup; | |
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken'; | |
$tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl); | |
$tokenArray = $yt->getFormUploadToken($myVideoEntry); | |
$tokenValue = $tokenArray['token']; | |
$postUrl = $tokenArray['url']; | |
$nextUrl = 'http://vitorpacheco.com'; | |
// build the form | |
$form = '<form action="'. $postUrl .'?nexturl='.$nextUrl . | |
'" method="post" enctype="multipart/form-data">' . | |
'<input name="file" type="file" />' . | |
'<input name="token" type="hidden" value="'. $tokenValue .'" />'. | |
'<input value="Upload Video File" type="submit" />'. | |
'</form>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment