1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
public static void connexion()
{
//connexion
var request = (HttpWebRequest)WebRequest.Create("https://site.com/ajax.php");
var postData = "request=login&do_login=1&login=pseudo&password=motdepasse&stay_connected=1";
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.KeepAlive = true;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
Console.WriteLine("CONNEXION : "+responseString);
} |
Partager