2

我想使用具有这种形式的页面:

<form method="post" action="modules.php?name=search">
<input onkeypress=FKeyPress(this); onkeydown=FKeyDown(this); type="text" style="text-align:center" name="name"        size="30">&nbsp;</p>
 <img src='captcha.php' id='captcha' /><br /><br /><a href='#'  onclick='document.getElementById("captcha").src="captcha.php?"+Math.random();document.getElementById("captchaf").focus ();'id='change-image'>change</a><br/><p><strong>Enter captcha</strong><br>
 <input name="captcha" id="captchaf" type="text" style="text-align:center"></p><br />
 <input name="fbrsecured" type="hidden" value="">
 <input name="action" type="hidden" value="FBSend">
 <p><input type="submit" name="submit" value="search"></p>
 </form>

我展示了使用这个:

    EditText edcap = (EditText) findViewById(R.id.cap);
    ImageView cap = (ImageView) findViewById(R.id.capt);
    try{
        String url1 = "mysiteaddress/captcha.php";
        URL ulrn = new URL(url1);
        HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
        InputStream is = con.getInputStream();
        Bitmap bmp = BitmapFactory.decodeStream(is);
        if (null != bmp)
            cap.setImageBitmap(bmp);
        else
            System.out.println("The Bitmap is NULL");

        }catch(Exception e){}
    String capt = edcap.getText().toString();
    HttpPost httpPost = new HttpPost("http://eservice.postcode.post.ir/modules.php?name=Postalcode2");  
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();  
    nameValuePairs.add(new BasicNameValuePair("name", Name));  
    nameValuePairs.add(new BasicNameValuePair("captcha", Capt)); 
    nameValuePairs.add(new BasicNameValuePair("fbrsecured", ""));
    nameValuePairs.add(new BasicNameValuePair("action", "FBSend"));
    nameValuePairs.add(new BasicNameValuePair("submit", "search"));

我显示验证码并输入 edcap 但出现不正确的验证码错误。

4

1 回答 1

1

最后我找到了答案,我使用了 2 个 httpclient,这改变了 cookie 并导致了 Incorrect Captcha 错误

于 2012-05-10T12:54:19.420 回答