我需要一些幫助。我嘗試使用YouTube API上傳視頻。我在C#中使用Windows窗體。 這是我做的:youtube api:上傳不起作用
var service = new YouTubeService("kslmfkmlskf",this._sharedConfiguration.youtubeApiKey);
service.setUserCredentials(this._sharedConfiguration.youtubeUserName, this._sharedConfiguration.youtubeUserPassword);
var newEntry = new YouTubeEntry();
string title = "test";
string description = "test test test";
string keywords = "testa testb testc";
newEntry.Media = new Google.GData.YouTube.MediaGroup();
newEntry.Media.Categories.Add(new MediaCategory("Movies", YouTubeNameTable.CategorySchema));
newEntry.Media.Keywords = new MediaKeywords(keywords);
newEntry.Media.Description = new MediaDescription(description);
newEntry.Media.Title = new MediaTitle(title);
newEntry.MediaSource = new MediaFileSource("E:\\cine_buzz\\automate_trailer\\toupload\\demo.mov", "video/quicktime");
var createEntry = new YouTubeEntry();
createEntry = service.Upload(newEntry);
,我有一個異常返回是這樣的:
{Google.GData.Client.GDataRequestException: Execution of request failed: https://uploads.gdata.youtube.com/feeds/api/users/default/uploads ---> System.Net.WebException: Le serveur distant a retourné une erreur : (400) Demande incorrecte.
à System.Net.HttpWebRequest.GetResponse()
à Google.GData.Client.GDataRequest.Execute()
--- Fin de la trace de la pile d'exception interne ---
à Google.GData.Client.GDataRequest.Execute()
à Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
à Google.GData.Client.GDataGAuthRequest.Execute()
à Google.GData.Client.MediaService.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data)
à Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data)
à Google.GData.Client.Service.Insert[TEntry](Uri feedUri, TEntry entry)
à Google.GData.YouTube.YouTubeService.Upload(String userName, YouTubeEntry entry)
à Google.GData.YouTube.YouTubeService.Upload(YouTubeEntry entry)
à CineBuzzAutomateTrailer.frmUploadYoutube.upload() dans C:\Users\Yeurl\Documents\Visual Studio 2010\Projects\CineBuzzAutomateTrailer\CineBuzzAutomateTrailer\frmUploadYoutube.cs:ligne 105
à CineBuzzAutomateTrailer.frmUploadYoutube.btnTest_Click(Object sender, EventArgs e) dans C:\Users\Yeurl\Documents\Visual Studio 2010\Projects\CineBuzzAutomateTrailer\CineBuzzAutomateTrailer\frmUploadYoutube.cs:ligne 113
à System.Windows.Forms.Control.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.ButtonBase.WndProc(Message& m)
à System.Windows.Forms.Button.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.Run(Form mainForm)
à CineBuzzAutomateTrailer.Program.Main() dans C:\Users\Yeurl\Documents\Visual Studio 2010\Projects\CineBuzzAutomateTrailer\CineBuzzAutomateTrailer\Program.cs:ligne 18
à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()}
這
<errors xmlns="http://schemas.google.com/g/2005">
- <error>
<domain>GData</domain>
<code>InvalidEntryException</code>
<internalReason>Validation failed</internalReason>
</error>
</errors>
我不明白這有什麼錯我做什麼。 Thanx求助