This question is an additional complement to this question:
How to log in to Facebook using Java with software?
I used (a slightly modified version) the following code to log into the accounts of other sites just fine.
WebClient webClient = new WebClient();
HtmlPage page1 = webClient.getPage("http://www.facebook.com");
HtmlForm form = page1.getForms().get(0);
HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue("Login").get(0);
HtmlTextInput textField = form.getInputByName("email");
textField.setValueAttribute("bob@smith.com");
HtmlPasswordInput textField2 = form.getInputByName("pass");
textField2.setValueAttribute("ladeeda");
HtmlPage page2 = button.click();
However, when I try to login to facebook with the correct email and password, I have two problems:
SEVERE: Job run failed with unexpected RuntimeException: TypeError: Cannot find
function addImport in object [object].
(http://static.ak.fbcdn.net/rsrc.php/yC/r/gmR3y_ARtaM.js
Exception class=[com.gargoylesoftware.htmlunit.ScriptException]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "length"
from undefined (http://static.ak.fbcdn.net/rsrc.php/yC/r/gmR3y_ARtaM.js
What am I doing wrong?
source
share