Witam.
Poniższy skrypt uploaduje filmy na Youtube'a.
W formularzu chciałbym dodać inputy:text z tytulem i opisem filmu,
lecz aby wygenerować url akcji w formularzu muszę wczesniej ustawić parametry title , desc oraz kategoria.
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setVideoTitle('Tytul filmu');
$myVideoEntry->setVideoDescription('Opis filmu');
$myVideoEntry->setVideoCategory('Kategoria');
Jak zrobić by to użytkownik mógł wprowadzać tytul i opis, a nie ja w tym momencie te parametry są sztywno podane.
Czy ew. można jakoś po id filmu aktualizować wstawiony opis na własny...
if (!isset($_SESSION['sessionToken']) && !isset($_GET['token']) ){
$authUrl = Helper_Youtube::getAuthSubRequestUrl();
$youtubeForm =
<<<END
<h3>Wymagana autoryzacja!</h3>
<p><a href="$authUrl">Musisz uzyskać dostęp do alikacji zanim rozpoczniesz</a> .<p>
END;
//if token has been requested but not saved to a session then save the new token to a session
} else if (!isset($_SESSION['sessionToken']) && isset($_GET['token'])) {
$_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
}
if(isset($_SESSION['sessionToken'])) {
//authenticat with youtube
$httpClient = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']);
$developerKey = 'AI39si7DzQqPEc7tlcmJR8Ohils_6DsJ_3*****A_lVnfpueja-MpKBuPsJpghqezJFmoV-n1aYRR-wrKy2IA';
$applicationId = '14456169*******sercontent.com';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, NULL, $developerKey);
// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setVideoTitle('asdasdsadsadsad');
$myVideoEntry->setVideoDescription('jsadsadsadasdsadssadlm');
$myVideoEntry->setVideoCategory('Autos'); // The category must be a valid YouTube category!
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
// place to redirect user after upload
$nextUrl = 'http://localhost/fp/Wedding/Youtube/Add/';
// build the form
$youtubeForm =
<<<END
<form action="$postUrl?nexturl=$nextUrl" method="post" enctype="multipart/form-data">
<input name="file" type="file"/>
<input name="token" type="hidden" value="$tokenValue"/>
<div class="form-actions">
<button type="submit" name='videoupload' class="btn btn-blue">Zapisz plik!</button>
</div>
</form>
END;
if(isset($_GET['status']) && $_GET['status'] == '200'){ echo '<h1>Video Upload</h1>'; }
Ten post edytował soszin 28.05.2013, 15:46:51