簡體   English   中英

通過android webview問題自動登錄網站

[英]Auto logging in to website through android webview problems

我的銀行有一個我想自動登錄的移動網站。 這是網頁https://ib.absa.co.za/ib/AuthenticateW.do?icmpid=BAC00414

到目前為止,這是我的代碼。

    browser = (WebView)findViewById(R.id.webView1);
    browser.getSettings().setJavaScriptEnabled(true);

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("AccessAccount", "my_account_nr"));
        nameValuePairs.add(new BasicNameValuePair("PIN", "my_pin"));

        try {
            browser.loadData(CustomHttpClient.executeHttpPost(BASE_URL, nameValuePairs), "text/html", "utf-8");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

BASE_URL是頂部的鏈接。 我從http://code.google.com/p/virtualwalks/source/browse/trunk/virtualwalks/project7/Android/CustomHttpClient.java?spec=svn177&r=177獲得了CustomHttpClient

這是網頁標題:

請求URL:https://ib.absa.co.za/ib/AuthenticateW.do?icmpid = BAC00414

請求方法:GET

狀態碼:200 OK

請求標題查看源

接受:text / html,application / xhtml + xml,application / xml; q = 0.9, / ; q = 0.8

接受字符集:ISO-8859-1,utf-8; q = 0.7,*; q = 0.3

接受編碼:gzip,deflate,sdch

接受語言:en-US,en; q = 0.8,af; q = 0.6

連接方式:保持活躍

主持人:ib.absa.co.za

引薦來源:http://www.absa.mobi/

用戶代理:Mozilla / 5.0(Linux; U; Android 2.3.6; zh-cn; Nexus S Build / GRK39F)AppleWebKit / 533.1(KHTML,like Gecko)Version / 4.0 Mobile Safari / 533.1

查詢字符串參數查看URL編碼

icmpid:BAC00414

響應標題查看源

緩存控制:無緩存,必須重新驗證

連接:保持活動

內容編碼:gzip

內容語言:zh-CN

內容類型:文本/ html;字符集= ISO-8859-1

日期:2012年10月10日,星期三07:57:50 GMT

過期:格林尼治標准時間1970年7月12日星期日2:00:00

保持活動:超時= 10,最大值= 20

語法:無快取

Set-Cookie:JSESSIONID = 0000CTls0Onsd_DJkBrN0FLy9eq:11l21e8a2; 路徑= / ib; Domain = absa.co.za;安全

傳輸編碼:分塊

變體:接受編碼,用戶代理

和html代碼:

<html>

Absa手機銀行

<body text="#000000" bgcolor="#FFFFFF">
    <p align="left" style="text-align:left;" class="pgHeadTop"><img src="/ib/images/wap/menu/absa_98x27.gif" alt="Logo" border="0"> <p align="left" style="text-align:left;" class="pgHeadBottom">Logon </p>

        <form action="https://vs1.absa.co.za/ib/AuthenticateW.do;jsessionid=0000CTls0Onsd_DJkBrN0FLy9eq:11l21e8a2" method="post" autocomplete="OFF"><input type="hidden" name="_channelIdentifier_" value="W">


                <p align="left" style="text-align:left;">
                    <p align="left" style="text-align:left;" class="tooltip">Enter your access account number</p>
                    <input type="text" name="AccessAccount" value="" maxlength="16" size ="16" istyle="4">
                </p>

            <p align="left" style="text-align:left;">
                <p align="left" style="text-align:left;" class="tooltip">Enter your PIN</p>
                <input type="password" name="PIN" value="" maxlength="5" size ="5" istyle="4">
            </p>
            <p align="left" style="text-align:left;">
                <p align="left" style="text-align:left;" class="tooltip">Enter your user number</p>
                <input type="text" name="user" value="1" maxlength="4" size ="5" istyle="4">
            </p>
            <p align="left" style="text-align:left;">
                <p align="left" style="text-align:left;" class="heading">It is your responsibility to ensure the secrecy of your PIN number.</p>
            </p>
            <p align="left" style="text-align:left;">
                <input type="submit" name="button_processPIN" value="Next &gt;" /><input type="hidden" name="processPIN_params" value="controller=com.sirius.apps.ib.view.wap.user.AuthenticateCntrl&amp;state=processPIN"/><input type="hidden" name="processPIN_encoding" value="u"/><input type="hidden" name="cmd" value="button"/>
            </p>
            <input type="hidden" name="AUTH_RND" value="a2f7ea6e">
            <input type="hidden" name="JAVASCRIPT" value="Y">
            <input type="hidden" name="LOGON" value="1">
        </form>
        <p align="left" style="text-align:left;" class="pageFooter"><a href="https://ib.absa.co.za/ib/RegisterW.do;jsessionid=0000CTls0Onsd_DJkBrN0FLy9eq:11l21e8a2?_Uid_=1&amp;_channelIdentifier_=W&amp;_language_=en" style="color:#FFFFFF;">Register</a> | <a href="https://ib.absa.co.za/ib/ContactUsW.do;jsessionid=0000CTls0Onsd_DJkBrN0FLy9eq:11l21e8a2?_Uid_=1&amp;_channelIdentifier_=W&amp;_language_=en" style="color:#FFFFFF;">Contact</a> | </p><p align="right" style="text-align:right;" class="body"><img src="/ib/images/wap/menu/barclays_84x25.gif" alt="Barclays" border="0"></p>



</body>

如果我運行該程序,它將僅加載登錄頁面。

只是希望有人可以對此有所啟發,如果可以的話,或者我的代碼有錯誤/缺少/愚蠢的。

它們可能與用戶代理匹配,並且在使用此自定義http客戶端時,您可能沒有有效的用戶代理。

將用戶代理設置為與您的Android瀏覽器使用的相同,並且您應該能夠加載該頁面。

一個可能的值是:

Mozilla/5.0 (Linux; U; Android 1.1; en-gb; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2 – G1 Phone

否則,以編程方式獲取它:以編程方式獲取User-Agent

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM