通过data api从asp.net网站上传视频失败到youtube

时间:2013-04-23 11:04:55

标签: asp.net youtube

我正在尝试使用数据API将我的ASP.net网站上的视频上传到YouTube,但我收到此错误:“远程服务器返回错误:(403)禁止。”

我使用以下代码:

YouTubeRequestSettings设置=新的YouTubeRequestSettings(“VideoPortal”,“Developer_Key”,“用户名”,“密码”);         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);

有人可以告诉我如何使这段代码工作并解决错误吗?

1 个答案:

答案 0 :(得分:0)

当您收到HTTP 403响应时,HTTP响应正文的内容是什么?响应正文中应该有一条错误消息,提供对错误的解释