Answer

08/04/2012 14:38 pippo2040#1
I'm coding a program and i want make a login whit this forum using HttWebRequest. It's possible made this?Someone can help me pls?
Thx
Pippo
08/04/2012 15:56 vwap#2
Yes, it's possible.
You could use a firefox addon like "Live HTTP Headers" to get the post-data you have to send.
08/05/2012 15:07 pippo2040#3
Code:
static string login(string url, string username, String password)
        {      
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
            string cookie = "";
            string values = "vb_login_username=" + username + "&vb_login_password=" + password
                                + "securitytoken=guest&"
                                + "cookieuser=checked&"
                                + "do=login";
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            req.ContentLength = values.Length;
            CookieContainer a = new CookieContainer();
            req.CookieContainer = a;

            System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error

            using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)) { writer.Write(values); }

            HttpWebResponse c = (HttpWebResponse)req.GetResponse();
            foreach (Cookie cook in c.Cookies) { cookie = cookie + cook.ToString() + ";"; }

            return cookie;
        }
where I'm doing wrong?
I don't know if it connects or not