Создание формы для прямой загрузки API YouTube - PullRequest
1 голос
/ 21 января 2011

Итак, у меня есть скрипт, который загружает видео на YouTube:

$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
$myVideoEntry->setVideoCategory('Autos');
$myVideoEntry->setVideoPrivate();
$myVideoEntry->SetVideoTags('cars, funny');

$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://example.com/formprocess.php';

// build the form
$form = '<form id="youtube_upload" action="'. $postUrl .'?nexturl='. $nextUrl .
        '" method="post" enctype="multipart/form-data" target="uploader">'. 
        '<input id="video_title" name="video_title" type="text"/>'.
        '<input id="file_upload" name="file_upload" type="file"/>'. 
        '<input name="token" type="hidden" value="'. $tokenValue .'"/>'.
        '<input value="Upload Video File" type="submit" />'. 
        '</form><iframe id="uploader" name="uploader" style="display: none; width: 500px; height: 200px; border:1px solid #000;"></iframe>
';

echo $form;

, который работает отлично.Единственная проблема, с которой я сталкиваюсь - я не могу назвать свои видео через форму.Я хотел бы иметь возможность ввести название, описание и т. Д. Видео, а затем загрузить их.Идеи?

1 Ответ

0 голосов
/ 28 мая 2011

Это базовая часть API данных Google / Youtube:

$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($ytTitle); // Set the title
$myVideoEntry->setVideoDescription($ytDesc); // Set the description
$myVideoEntry->setVideoCategory($ytCat);
$myVideoEntry->SetVideoTags($ytTags);

Вероятно, лучше всего прочитать всю документацию по API;так как там довольно много функций.

...