Как сделать post авторизацию?
string token = string.Empty;
string GenLink = "http://ask.fm/";
HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(GenLink);
myRequest.Method = "GET";
myRequest.Timeout = 15000;
myRequest.AllowAutoRedirect = true;
myRequest.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
StreamReader Reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string page = Reader.ReadToEnd();
Match res = Regex.Match(page, "var AUTH_TOKEN = \"(.*)\";");
token = res.Groups[1].ToString();
Reader.Close();
return token;
HttpWebRequest POST = (HttpWebRequest)HttpWebRequest.Create("http://ask.fm/session");
POST.Method = "POST";
POST.Timeout = 15000;
POST.AllowAutoRedirect = true;
POST.ContentType = "application/x-www-form-urlencoded";
string data = "authenticity_token="+token+"&login=vk_groups&password=363534qwa&follow=&like=&back=&authenticity_token="+token;
byte[] byteData = Encoding.UTF8.GetBytes(data);
POST.ContentLength = byteData.Length;
Stream stream = POST.GetRequestStream();
stream.Write(byteData, 0, byteData.Length);
string response = new StreamReader(POST.GetResponse().GetResponseStream()).ReadToEnd();
Пытаюсь сделать вот так, но не получается ничего. Вот что отправляется:
authenticity_token=WWRqTElVSCMg4LvjrQVq%2BgjmDZ%2BjbVcM3LBPTGZHhLQ%3D&login=volodiaklicko2&password=&follow=&like=&back=&authenticity_token=WWRqTElVSCMg4LvjrQVq%2BgjmDZ%2BjbVcM3LBPTGZHhLQ%3D ----