1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| <?php
require_once( 'Zend/Gdata/YouTube.php' );
require_once( 'Zend/Gdata/ClientLogin.php' );
/* _____________________________________________________________________________________________________ */
$auth = 'https://www.google.com/youtube/accounts/ClientLogin' ;
$dev_key = 'ma cle de developpeur' ; // Clé développeur changer pour l'exemple sinon la mienne est correct
$app_id = 'ytapi-' ; // Identifiant de l'application
$client_id = 'ytapi-' ; // Identifiant du client
$user = 'user' ; // Utilisateur changer pour l'exemple sinon le mien est correct
$passwd = 'password' ; // Password changer pour l'exemple sinon le mien est correct
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
$user,$passwd,'youtube',null,'MonSiteWeb',null,null,$auth
);
$youtube = new Zend_Gdata_YouTube( $httpClient, $app_id, $client_id ,$dev_key );
/* _____________________________________________________________________________________________________ */
$video = new Zend_Gdata_YouTube_VideoEntry() ;
/* Infos sur la vidéo */
$video->setVideoTitle( 'Titre de ma video' );
$video->setVideoDescription( 'Description de ma video' );
$video->setVideoCategory( 'Sports' );
$video->SetVideoTags( 'motclé1, motclé2' );
$video->SetVideoDeveloperTags(array( 'mydevtag', 'anotherdevtag' ) );
/* _____________________________________________________________________________________________________ */
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $youtube->getFormUploadToken($video, $tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
/* _____________________________________________________________________________________________________ */
$nextUrl = 'localhost';
?>
<form
action="<?php htmlspecialchars( $postUrl, ENT_QUOTES ).'?nexturl='. urlencode( $nextUrl ) ?>"
method="post"
enctype="multipart/formdata"
>
Fichier vidéo : <input name="file" type="file" />
<input name="token" type="hidden" value="<?php $tokenValue ?>"/>
<input type="submit" value="Envoyer la vidéo"/>
</form> |
Partager