I am currently using the WebClient in the Gargoylesoftware package and Apache Commons stuff..
I'm trying to login to Steam via a Javabased WebClient. For whatever reason, this damn site NEVER lets me login!
Can anyone point me in the right direction? My code is below:
public void doLogin(){
System.out.println("Grabbing first page..");
HtmlPage loginPage;
try {
javabasedWebClient.setJavaScriptEnabled(true);
javabasedWebClient.setRedirectEnabled(true);
yummy = new CookieManager();
javabasedWebClient.setCookieManager(yummy);
yummy.setCookiesEnabled(true);
loginPage = javabasedWebClient.getPage("https://store.steampowered.com/login/");
System.out.println("Got the page!");
// Setup the User
final HtmlTextInput user = loginPage.getHtmlElementById("steamAccountName");
user.setText("user");
System.out.println(user.getText());
// Setup the password
final HtmlPasswordInput word = loginPage.getHtmlElementById("steamPassword");
word.setText("password");
System.out.println(word.getText());
HtmlPage test = loginPage.getHtmlElementById("imageLogin").click();
String[] itemPageCode = test1.asXml().split("\n");
for (int i=0;i<itemPageCode.length;i++){
System.out.println(itemPageCode[i]);
}
checkLoggedIn(itemPageCode);
} catch (FailingHttpStatusCodeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I finally figured it out. For some reason, if I basically do this function TWICE it then logs in correctly. Why? I have no idea O_o