我正在尝试向 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;
}
我的代码有什么问题?