我使用curl PHP从Jcaptcha获取图像。
hidCaptchaID由Jcaptcha生成。
问题是我不断收到错误说明无效的验证码,我知道我输入的验证码是正确的。
我使用curl发送hidCaptchaID,inCaptchaChars和其他数据
我已经检查过firefox firebug的头请求,它实际上和通过CURL发送一样。会话和cookie也是一样的。
可能有什么问题?
注意:我的问题与验证码旁路/断路器无关。我手动输入验证码,然后使用curl发送。
代码:
<?php
$cookiesPath = "c:/wamp/www/cookies";
$a = session_id();
if ($a == '') session_start();
if ($_GET) {
$form_link = $_GET['newURL'];
unset($_GET['newURL']);
$postDataCapcha = http_build_query($_GET);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "\BuiltinObjectToken-VerisignClass3xxxxxxxxxxxxxxxxxxxxxxx.crt");
curl_setopt($ch, CURLOPT_URL, "https://xxxxx.xxxxx.co.uk/xxxxx/xxxxx/" . $form_link );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postDataCapcha);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_COOKIE, "JSESSIONID=xxxxxxxxxxxxx:xxxxxxxxx");
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiesPath . "/cookiefile.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiesPath . "/cookiefile.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$PagaeCapcha = curl_exec($ch);
echo "<hr><br />";
echo($PagaeCapcha);
exit();
}
<form action="index.php" method="get">
Number: <br />
<input name="existing_mobile_number" id="existing_mobile_number" type="text">
<br /><br />
Customer Postcode:<br />
<input name="customer_postcode" id="customer_postcode" type="text">
<br /><br />
Capcha Code:<br />
<input id="captchauserid" name="inCaptchaChars" type="text">
<input name="hidCaptchaID" value="<?php echo $capcha_id['0']->value; ?>" type="hidden" />
<input name="newURL" type="hidden" value="<?php echo $capchalink; ?>" />
<input value="Go!" type="submit" />
</form>