我正在尝试使用数据 API 将 ASP.net 网站中的视频上传到 YouTube,但出现此错误:“远程服务器返回错误:(403) Forbidden。”
我正在使用以下代码:
YouTubeRequestSettings settings = new YouTubeRequestSettings("VideoPortal", "Developer_Key", "username", "password"); YouTubeRequest 请求 = 新的 YouTubeRequest(设置);
视频 newVideo = new Video();
newVideo.Title = "testvideo";//txttitle.Text.Trim();
newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "testvideo";//txtkeyword.Text.Trim();
newVideo.Description = "testvideodesc";//txtdesc.Text.Trim();
newVideo.YouTubeEntry.Private = false;
newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag",
YouTubeNameTable.DeveloperTagSchema));
newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122);
// alternatively, you could just specify a descriptive string
// newVideo.YouTubeEntry.setYouTubeExtension("location", "Mountain View, CA");
string path = Server.MapPath("video/Screen-Recording.mov");
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(path,
"video/quicktime");
settings.Timeout = 100000000;
Video createdVideo = request.Upload(newVideo);
有人可以向我建议如何使此代码正常工作并解决错误吗?