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。我使用此代码来完成这项工作,但它不起作用。没有错误但没有任何反应。我的这段代码有什么问题?您可以在网址中查看视频ID和评论ID。