私はYoutube DataAPIを使用して、サイトのYouTubeアカウントに動画をアップロードしようとしています。私はthe documentation for Browser-based uploadingで提供されている例を使用しており、私は基本的な例を得ることができます。問題は、これをjQueryで使用できるメソッドに変換することができないことです。YouTube APIとjQueryを使ってYouTubeに動画をアップロードするにはどうすればよいですか?
私のコードでは、ビデオのメタデータ値をすでに設定してあり、Data APIからのアップロードのトークン値を受け取っています。しかし、ときに私は、アップロードを行うためのjQueryを実行しようとするが、uploads.gdata.youtube.comは私に、以下の(フィドラーの礼儀)を与える:ここでは
HTTP/1.1 404 Not Found
Server: Upload Server Built on Nov 11 2010 15:36:58 (1289518618)
Date: Mon, 22 Nov 2010 01:44:58 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate
Content-Length: 0
Content-Type: text/html
はフォームです。
<form action="#" method="post" name="video_upload" enctype="multipart/form-data">
<div class="field-group">
<label style="margin-top:0px" for="video_name">video title</label>
<input type="text" value="" class="required" tabindex="1" name="video_name" id="video_name">
<div id="video_name_status"></div>
</div>
<div class="field-group">
<label for="video_description">description</label>
<textarea class="required" tabindex="2" name="video_description" rows="5" cols="40" id="video_description"></textarea>
<div id="video_description_status"></div>
</div>
<div class="field-group">
<label for="video_path">video file</label>
<input type="file" value="" class="required" tabindex="3" name="video_path" id="video_path">
<div id="video_status"></div>
</div>
<div id="form-button-group">
<input type="submit" value="Upload Video" name="submit" id="signup-button">
</div>
<div class="youtube-disclaimer">
By clicking 'Upload Video' you certify that you own all rights to the content or that you are authorized by the owner to
make the content publicly available on YouTube, and that it otherwise complies with the YouTube Terms of Service located
at <a href="http://www.youtube.com/t/terms">http://www.youtube.com/t/terms</a>.
</div>
</form>
それはここに:私はキックオフjQueryの$("form").submit
を使用して呼び出しますが、私はAJAXを通じて、すべてをやってみたいので、適切な行動がどうあるべきかわからないのですため、アクションは、現在、「#」に設定されています私は、呼び出しを実行するために使用していますjQueryの(データはユーチューブポストURLを保持している私のサーバーから以前のjQueryの呼び出し、トークン、および成功を示す値で返されるJSONです):
if (data.success == true){
$.ajax({
async : false,
type: "POST",
url: data.postUrl + "?nexturl=www.mysite.local",
data: ({file : $('#video_path'),
token : data.tokenValue,
alt : 'json-in-script'}),
contentType : 'multipart/form-data',
processData: false,
datatype: 'jsonp',
jsonpCallback: 'processVideoResponse',
success: function(data){
alert("success alert" + data);
},
error: function(data){
alert("error" + data);
}
});
なって最後に、アップロードされたビデオは問題の半分です。 YouTubeがビデオを受け入れたり拒否したりすると、ブラウザはnexturlパラメータにリダイレクトされ、ステータスを示すparamsが追加されます。これをjQuery経由で送信するとどうすれば処理できますか?
理解しましたか?私は同じ問題に直面しています! – Tom
@TomクライアントからYouTubeへ正しく動作することはありませんでした。ファイルをサーバーに移動し、そこから直接アップロードを実行することにしました。今後は、これを元のアイデアに近いものにリファクタリングしたいと考えています。 – Steven
こんにちは申し訳ありませんが、私はあなたの後ろに一歩です、私はYouTubeにビデオをアップロードするPHPファイルをコーディングしようとしています。あなたは私を導くことができますか?私はzendフレームワークを使用してみましたが、エラーが発生しました。 http://stackoverflow.com/questions/7628677/accessing-youtube-services-from-php 代替品を探しています。助けてください。あなたが何らかの方法を知っているなら – shababhsiddique