【问题标题】:Post form includes captcha by httpPost发布表单包括 httpPost 的验证码
【发布时间】:2012-04-25 11:19:59
【问题描述】:

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

<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 但出现不正确的验证码错误。

【问题讨论】:

  • 您设置图像并立即尝试阅读答案。你怎么有时间在两行连续的代码之间输入文本? cap.setImageBitmap(bmp); String capt = edcap.getText().toString();。我认为您应该将验证码显示和发送分成 2 个不同的功能。
  • 我在 2 个单独的函数中执行此操作
  • 那么问题应该是html形式的。我只使用 google recaptcha,它需要 captcha_key 和 captcha_answer。但是在你的例子中你只使用了答案,我认为答案是不够的。
  • 我认为它由 phpsessid 工作,我不知道如何处理。

标签: android forms http-post captcha


【解决方案1】:

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

【讨论】:

  • 嘿,你可以分享你使用 2 HttpClient 的那部分代码,因为我遇到了同样的错误。
猜你喜欢
  • 1970-01-01
  • 2014-07-11
  • 2013-04-10
  • 2014-06-19
  • 2016-09-08
  • 1970-01-01
  • 1970-01-01
  • 2016-04-12
  • 1970-01-01
相关资源
最近更新 更多