2015-09-25 105 views
0

由於httpURLconnection沒有切斷,我切換到htmlUnit以編程方式獲得授權代碼以從instagram獲取訪問令牌,然後從那裏做任何我需要的事情,事情是我「M卡住試圖從URL使用HtmlUnit獲取來自instagram的訪問令牌

mysite.com/?code=ca1ec5b06a0b409293cff74ed9876a46

獲取授權碼,但因爲它似乎並不被重定向我無法訪問該鏈接從授權URL。這一個:

https://instagram.com/accounts/login/?force_classic_login=&next=/oauth/authorize/%3Fclient_id%CLIENT_ID%26redirect_uri%3Dhttp%3A//MYSITE.COM%26response_type%3Dcode

這是我的代碼,我嘗試訪問該網址:

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38); 
    webClient.getOptions().setJavaScriptEnabled(true); 
    webClient.getOptions().setRedirectEnabled(true); 
    webClient.getOptions().setThrowExceptionOnScriptError(false); 
    webClient.getOptions().setCssEnabled(true);  
    HtmlPage page = (HtmlPage) webClient.getPage(authURL); 
    WebResponse response = page.getWebResponse(); 
    String content = response.getContentAsString(); 
    System.out.println(page.getUrl()); 
+2

您需要找出根本原因,請完整閱讀http://htmlunit.sourceforge.net/submittingJSBugs.html –

回答

相關問題