MyBB Community Forums

Full Version: Login and check usergroup on MyBB 1.8 using C#
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, so i build this class where you can login to mybb 1.6, it was easy since it had no redirects, but now it's pretty hard to access and download the html source of the usercp.php page, since once i log in and get redirected in c# code, i get the source html of when you're not logged in, with the error and the login form all over again. This is my Class:
public string MakePostRequest(string url = "www.website.com/usercp.php", string postData = "username=" + Username + "&password=" + Password + "&remember=yes&submit=Login&action=do_login&url=" + ForumURL + "member.php?action=login")
        {
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
            request.CookieContainer = cookieMoster;
            request.UserAgent = UserAgent;
            request.KeepAlive = true;
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.AllowAutoRedirect = true;

            byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(postData);
            request.ContentLength = postBytes.Length;
            Stream requestStream = request.GetRequestStream();
            requestStream.Write(postBytes,0,postBytes.Length);
            requestStream.Close();

            HttpWebResponse response = (HttpWebResponse) request.GetResponse();
            StreamReader sr = new StreamReader(response.GetResponseStream());
            string sReturn = sr.ReadToEnd();
            sr.Dispose();

            return sReturn;
        }

Anyone can help ?
This may be better suited to the Third Party Integration forum.

Out of curiosity, why are you wrapping MyBB with C#?
(2014-09-03, 10:34 PM)laie_techie Wrote: [ -> ]This may be better suited to the Third Party Integration forum.

Out of curiosity, why are you wrapping MyBB with C#?

I don't know about the first suggestion.

Well i need to make it as to members of my forum can get new and other stuff in the gui i am making. So i need to make sure they aren't banned or awaiting activation.