Hello Developers!
Thank you for taking the time to read this email. Any insight would be greatly appreciated. I am attempting to log into a website automatically using a PostMethod. I'm having trouble getting the cookies / session lined up properly to do so. Below is the code I am working with. Any suggestions / guidance is appreciated!
** Process results **
Thank you in Advance,
Chris
Thank you for taking the time to read this email. Any insight would be greatly appreciated. I am attempting to log into a website automatically using a PostMethod. I'm having trouble getting the cookies / session lined up properly to do so. Below is the code I am working with. Any suggestions / guidance is appreciated!
Code:
HttpClient Loginclient = new HttpClient();
PostMethod post = new PostMethod("http://www.throneit.com/forums/ucp.php?mode=login");
NameValuePair[] logindata =
{
new NameValuePair("username", "Cadicus"),
new NameValuePair("password", "###Censored###"),
new NameValuePair("autologin", "checked"),
new NameValuePair("login", "Login"),
new NameValuePair("sid", sessionID) <-- Do I need to provide this? If so, How can I pull the session ID from a post?
};
post.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
post.setQueryString(data);
Loginclient.executeMethod(post);
String htmlCode = post.getResponseBodyAsString();
Thank you in Advance,
Chris