byte[] bytes = ASCIIEncoding.UTF8.GetBytes("");
HttpWebRequest postReq = (HttpWebRequest)WebRequest.Create("https://instagram.com/web/likes/" + ID + "/like/");
WebHeaderCollection postHeaders = postReq.Headers;
postReq.Method = "POST";
postReq.Host = "instagram.com";
postReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0";
postReq.Accept = "*/*";
postHeaders.Add("Accept-Language", "it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3");
postHeaders.Add("Accept-Encoding", "gzip, deflate");
postHeaders.Add("X-Instagram-AJAX", "1");
postHeaders.Add("X-CSRFToken", CSRF);
postHeaders.Add("X-Requested-With", "XMLHttpRequest");
postReq.Referer = "https://instagram.com/";
postReq.CookieContainer = cookies;
postReq.KeepAlive = true;
postHeaders.Add("Pragma", "no-cache");
postHeaders.Add("Cache-Control", "no-cache");
postReq.ContentLength = bytes.Length;
Stream postStream = postReq.GetRequestStream();
postStream.Write(bytes, 0, bytes.Length);
postStream.Close();
HttpWebResponse postResponse;
postResponse = (HttpWebResponse)postReq.GetResponse();
StreamReader reader = new StreamReader(postResponse.GetResponseStream());
ID 是一个26个字符的数字,每张照片总是不同的。 我使用 Live HTTP Headers 获得了标题,它们与我的请求相同。 这是完整的错误描述: “ System.dll中发生了'System.Net.WebException'类型的未处理异常 附加信息:远程服务器返回错误:(403)禁止。“
有什么想法吗?在此先感谢您的帮助:)。