帖子表格包括httpPost的验证码

时间:2012-04-25 11:19:59

标签: android forms http-post captcha

我想要使用具有以下形式的页面:

<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但发生了错误的验证错误。

1 个答案:

答案 0 :(得分:1)

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