
15.02.2010, 17:51
|
|
Reservists Of Antichat - Level 6
Регистрация: 12.02.2006
Сообщений: 891
Провел на форуме: 1892597
Репутация:
836
|
|
ужс =\
Авторизация заключается в том чтобы пихнуть кукисы вовремя.
В принципе можно вот так:
Код:
protected override string SendPost(string url, string postData, string referer, bool allowRedirect)
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.AllowAutoRedirect = allowRedirect;
httpWebRequest.Method = "POST";
httpWebRequest.UserAgent = UserAgent;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
if (!string.IsNullOrEmpty(Proxy))
{
httpWebRequest.Proxy = new WebProxy(Proxy);
}
if (!string.IsNullOrEmpty(Cookies))
{
httpWebRequest.Headers.Add(HttpRequestHeader.Cookie, Cookies);
}
if (!string.IsNullOrEmpty(referer))
{
httpWebRequest.Referer = referer;
}
var buffer = Encoding.ASCII.GetBytes(postData);
httpWebRequest.ContentLength = buffer.Length;
using (var writer = httpWebRequest.GetRequestStream())
{
writer.Write(buffer, 0, buffer.Length);
}
using (var httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse())
{
Cookies = string.IsNullOrEmpty(httpWebResponse.Headers["Set-Cookie"]) ? "" : httpWebResponse.Headers["Set-Cookie"];
using (var stream = httpWebResponse.GetResponseStream())
{
using (var reader = new StreamReader(stream, Encoding.GetEncoding(1251)))
{
return reader.ReadToEnd();
}
}
}
}
__________________
*********************************
*Я не волшебник ٩(๏̯͡๏)۶, только учусь...*
*********************************
Программы на заказ
Times to fly...
|
|
|