標準の Zend Youtube ライブラリを使用して、動画を Youtube にアップロードしています。うまく機能していますが、更新せずにアップローダーを動作させる必要があります。
私はそれを達成しようとしましたが、常に取得しました: 302 YouTube アップロード URL からの応答が見つかりました, 400 不足しているトークンがスクリプトに送信されました
アップローダを作成するメソッド
public static function showUploadForm($presenter, $id, $name, $comment) {
$yt = self::getYt(); // these are the account settings
// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setVideoTitle($name);
$myVideoEntry->setVideoDescription($comment);
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('People');
// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->SetVideoTags('hockey');
$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 = $presenter->link('//User:videoUploaded', array('id' => $id)); //framework action
// build the form
$form = '<form id="youtubeUploader" class="ajaxSetVideoData" action="' . $postUrl . '?nexturl=' . $nextUrl .
'" method="post" enctype="multipart/form-data">' .
'<input id="file" name="file" type="file" />' .
'<input name="submit" type="submit" value="send" />' .
'<input name="token" type="hidden" value="' . $tokenValue . '"/>'.
'</form>' .
'<br />';
return $form;
}
よろしくお願いします。
編集:入力「トークン」のみがパラメーターとしてYouTube URLに送信されることがわかりました。
EDIT2 : AJAX とファイルのアップロードに問題がありました。このプラグインで動作しています: http://malsup.com/jquery/form/#code-samples
しかし、今でも両方のスクリプトで 302 Found を取得していますが、URL の「ステータス」は 200 (2 行目) で、問題ありません。ビデオもアップロードされています。