2011-01-21 10 views
1

だから私はユーチューブに動画をアップロードするスクリプトを持っています。完璧に働いているフォームの作成YouTubeのAPIを直接アップロード用

$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; 

。私が抱えている唯一の問題は、私のビデオにフォームの名前を付けることができないことです。私は、ビデオのタイトルや説明などを入力してアップロードできるようにしたいと思います。アイデア?

+0

なぜ直接アップロードにフォームを使用していますか?ブラウザのアップロードではありませんか? – cikatomo

答えて

0

これは、Google/YouTubeのデータAPIの基本的な部分である:

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

おそらく最高のAPIドキュメントのすべてを読み取るために、そこにはかなりの機能があります。

+0

私は正しい方向に、ありがとう! – Tom

関連する問題