远程服务器返回错误:(403)在youtube上从c#上传视频时被禁止

时间:2016-12-23 10:06:03

标签: c# youtube-api

我正在尝试从我的c#项目在youytube上传视频 这是我的设计页面

 <asp:FileUpload ID="fileupload" runat="server" />
        <asp:Button ID="btnsubmit" runat="server" Text="upload" OnClick="btnsubmit_Click" />

这是我背后的代码

protected void btnsubmit_Click(object sender, EventArgs e)
{
YouTubeModel youtubeModel;
YouTubeRequestSettings settings;
YouTubeRequest request;
string devkey = "my dev key";
string filename = Path.GetFileName(fileupload.FileName);
fileupload.SaveAs(Server.MapPath("~/App_Data/") + filename);
string path = Server.MapPath("~/App_Data/") + filename;
string filepath = Path.GetFullPath(path);
settings = new YouTubeRequestSettings("youtube", "my clientid", devkey);
request = new YouTubeRequest(settings);
settings.Timeout =  int.MaxValue;
Video video = new Video();
video.Title = "Sample Video Title";
video.Description = "Sample Video Description";
video.Tags.Add(new MediaCategory("Comedy", YouTubeNameTable.CategorySchema));
video.Keywords = "Comedy";
video.Private =false;
video.MediaSource = new MediaFileSource(filepath, "video/quicktime");
Video createdVideo = request.Upload(video);
}

我使用了像

这样的名称空间
using Google.GData.Extensions;
using Google.GData.Client;
using Google.GData.YouTube;
using Google.GData.Extensions.MediaRss;
using Google.YouTube;

我已经安装了google Api v3,我已经生成了ClientId密钥和Developer密钥 什么是probelm?我已经在谷歌搜索但无法得到正确的解决方案..我应该怎么做才能解决这个问题?谁能帮助我?

0 个答案:

没有答案