2
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.youtube.com/comment_voting?");
request.Method = "POST";
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.AllowAutoRedirect = false;
request.Host = "www.youtube.com";
request.Referer = "http://www.youtube.com/all_comments?v=XMb63nsvQMo";
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
string postData = "a=-1&id=ElmOl_qgg14TOf2QjsVeF92YakgUMR8CTnKEbN8Rmqg&video_id=XMb63nsvQMo&old_vote=0";
byte[] postBuffer = UTF8Encoding.UTF8.GetBytes(postData);
using (Stream postStream = request.GetRequestStream())
{
    postStream.Write(postBuffer, 0, postBuffer.Length);
}
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

我正在处理 youtube 视频中的投票评论。Youtube API 不支持该投票评论,因此我将为此使用 webrequesting。我使用这段代码来完成这项工作,但它不起作用。没有错误,但没有任何反应。我的这段代码有什么问题?您可以在 URL 中看到视频 ID 和评论 ID。

4

0 回答 0