Ja bym to widział tak. Trochę już tam masz zrobione.
public class HTTPClient
{
public CookieContainer Cookies { get; set; } //new
public string GetResponse(string Url, string PostData = "")
{
/*
HttpWebRequest
dodaj naglowki: accept, seragent, accept encoding,
ustaw automaticdecompression, timeout, allowautoredirect, cookiecontainer - Cookies
ustaw metode GET, POST (jesli PostData jest puste to bedzie get..
jesli post dodaj ContentType:application/x-www-form-urlencoded
zapisz do strumemia PostData
HttpWebResponse
dodaj ciastka do Cookies
uzyj StreamReader do odczytania strony :}
zwroc kod strony
*/
}
}
public class XupClient : IDisposable
{
private HTTPClient httpClient = new HTTPClient();
public void LogIn(string Login, string Password)
{
//uzywasz tak:
this.httpClient.GetResponse("http://sileent.xup.pl/login.php "); //pobierasz strone logowania
string Data = this.httpClient.GetResponse("http://sileent.xup.pl/login.php ", string.Concat("username=", HttpUtility.UrlEncode(Login), "&password=", HttpUtility.UrlEncode(Password), "&redirect=&login=Zaloguj"));
if (!Data.Contains("href=\"login.php?logout=true")) //sprawdzacz czy sie zalogowalo
throw new Exception("Błedny login lub hasło");
}
public void LogOut() {} //pobierasz link ktory wyloguje, potrzebne jest tutaj SID, ktore wyciagniesz ze strony po zalogowaniu
public void SendPost(string Forum, string Subject, string Message) {} //wysylanie wiadomosci: wchodzisz na forum, wchodzisz na strone tworzenia postu, wysylasz POST z wiadomoscia
}
a XupClient uzywasz tak:
try
{
using (XupClient xupClient = new XupClient())
{
xupClient.LogIn("test", "test123");
xupClient.SendPost("1", "temat", "wiadomosc"); //1- id forum
xupClient.LogOut();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
i gra :}
To tylko zarys programu, nie ma nic za free :DD A coś tam już masz zrobione to sobie chyba zrobisz.