How to Login to a Vbulletin Forum and get User group id in C# application

721 Views Asked by At

I would like to know how to login to a Vbulletin Forum and after it is confirmed login it gets the persons UserGroup ID and then in a label it will say the group name.

I can make it login from cookies. Example below, but I cannot figure out what needs done so it gets the usergroup id and then from the id it gets the name. Do I need to make a php file for it to get the information from or what exactly needs done?

    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;
    }
0

There are 0 best solutions below