这个问题有点像这个问题的补充: 如何使用 Java 以编程方式登录 Facebook?
我已经使用(稍微修改的版本)以下代码登录到其他网站的帐户就好了。
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();
但是,每当我尝试使用正确的电子邮件和密码登录 Facebook 时,都会遇到两个问题:
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#10)
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#10)
我究竟做错了什么?