我试图在YouTube上的视频中添加评论,有时,当我要在视频中添加评论时,YouTube向我发送以下错误:
请求执行失败:http://gdata.youtube.com/feeds/api/videos/ceVlltPBcHg/comments

异常的内部消息是:“远程服务器返回错误:(403)禁止。”

public bool commentVideo(string videoId)
{
       Uri Url = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoId);
       YouTubeRequestSettings s = new YouTubeRequestSettings(AppName, ApiKey,UserName,
                                                                  Password);
       s.Timeout = 10000000;
       YouTubeRequest account  = new YouTubeRequest(s);
       account.Proxy = GetProxyForUser(user);
       Video video = account.Retrieve<Video>(Url);//some times got exception
       string rating = commentRepository.getRating();
       Comment c = new Comment();
       c.Content = commentRepository.getComment();
       account.AddComment(video, c);
       Console.WriteLine("Comment successfully added to : " + videoId);
       return true;
}

我的代码有什么问题?

最佳答案

看来Google的qouta安全规则将错误返回给我的代码。当我长时间使用代码时,代码可以正常工作。

关于c# - YouTube API,C#.net-从YouTube获取视频信息有时失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16014545/

10-12 13:01
查看更多