Hola,
llevo bastante tiempo intentando realizar estas subidas pero hasta ahora no lo he conseguido. He usado el codigo de un tema que ya crearon en su momento (
http://www.forosdelweb.com/f18/subir...mi-web-929998/) para ir probando a ver si funciona. No sabia si continuar ese tema o crear uno nuevo, aunque al final lo he creado.
Mi codigo es el siguiente, con el error solucionado que tenia el usuario de ese tema:
Código PHP:
Ver originalrequire_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
// autenticacion
$authenticationURL= 'https://www.google.com/youtube/accounts/ClientLogin';
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
$password = 'micontraseña',
$service = 'youtube',
$client = null,
$source = 'miaplicacion', // a short string identifying your application
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);
$myDeveloperKey = 'LaClaveDeDeveloper'; // Esta clave la he obtenido de: http://code.google.com/apis/youtube/dashboard
$httpClient->setHeaders('X-GData-Key', "key=${myDeveloperKey}");
$yt = new Zend_Gdata_YouTube($httpClient);
// subir video
$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('file.mov');
$filesource->setContentType('video/quicktime');
// set slug header
$filesource->setSlug('file.mov');
// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);
// create a new Zend_Gdata_YouTube_MediaGroup object
$mediaGroup = $yt->newMediaGroup();
$mediaGroup->title = $yt->newMediaTitle()->setText('My Test Movie');
$mediaGroup->description = $yt->newMediaDescription()->setText('My description');
// the category must be a valid YouTube category
// optionally set some developer tags (see Searching by Developer Tags for more details)
$mediaGroup->category = array( $yt->newMediaCategory()->setText('Autos')->setScheme('http://gdata.youtube.com/schemas/2007/categories.cat'),
$yt->newMediaCategory()->setText('mydevelopertag')->setScheme('http://gdata.youtube.com/schemas/2007/developertags.cat'),
$yt->newMediaCategory()->setText('anotherdevelopertag')->setScheme('http://gdata.youtube.com/schemas/2007/developertags.cat')
);
// set keywords
$myVideoEntry->SetVideoTags('cars, funny');
// set video 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);
$entry->setWhere($where);
//upload URL for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
Y cuando intento usarlo me da el siguiente error:
Fatal error: Uncaught exception 'Zend_Gdata_App_AuthException' with message 'Authentication with Google failed. Reason: BadAuthentication' in /home/miapp/public_html/Zend/Gdata/ClientLogin.php:175 Stack trace: #0 /home/miapp/public_html/pruebas.php(19): Zend_Gdata_ClientLogin::getHttpClient('miusuario@g ma...', 'micontraseña', 'youtube', NULL, 'miaplicacion', NULL, NULL, 'https://www.goo...') #1 {main} thrown in /home/miapp/public_html/Zend/Gdata/ClientLogin.php on line 175
He probado mil formas y aun no se donde me equivoco. A ver si alguien me ilumina.