如何在 Xamarin.Forms(便携式)中使用 YouTubeRequest

How to use YouTubeRequest in Xamarin.Forms (Portable)

我想在用户点击 YouTube upload button 时从我的帐户上传 VideoYouTube,我只是想知道如果必须发送我该怎么办YouTube 上的流媒体内容。或者如何从流数据中获取视频的路径?

string developerkey = "api_key";
YouTubeRequestSettings settings = new YouTubeRequestSettings("Sample", developerkey , "email_id", "password");
YouTubeRequest request = new YouTubeRequest(settings);

Video newVideo = new Video();
newVideo.Title = "Video Title Here || ArgeKumandan";
newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "cars, funny";
newVideo.Description = "My description";
newVideo.YouTubeEntry.Private = false;
newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema));
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(@"‪C:\Users\Yudiz\Desktop\small.mp4", "video/mp4");

var createdVideo = request.Upload(newVideo);

谢谢。

您似乎在使用 YouTube API v2.0 的 Gdata 库。 Youtube v2.0 API 已弃用,不再有效。

Note: The YouTube Data API (v2) has been officially deprecated as of March 4, 2014. Please refer to our deprecation policy for more information. Please use the YouTube Data API (v3) for new integrations and migrate applications still using the v2 API to the v3 API as well.

此外,您不能使用客户端登录(登录名和密码)访问任何 google API。您将需要使用 Oauth2 来访问 YouTube API。

回答:您的代码将无效,因为您尝试访问的 API 不再有效。您将需要切换到使用 YouTube Data API.