Instantly share code, notes, and snippets.

@AZcaptcha /curl.php
Last active Oct 14, 2018

Embed
What would you like to do?
Simple captcha curl from azcaptcha.com
<?php
/**
Curl with image captcha from AZcaptcha.com
document https://azcaptcha.com/document
*/
$file_name_with_full_path = './dataset/cap_img_1_.jpg';
echo "<img src='$file_name_with_full_path' />";
$api_url = "http://azcaptcha.com";
$key = 'API_KEY_FROM_AZCAPTCHA';
if (function_exists('curl_file_create')) { // php 5.5+
$cFile = curl_file_create($file_name_with_full_path);
} else { //
$cFile = '@' . realpath($file_name_with_full_path);
}
//method base64
$fields = array(
'key' => $key,
'method' => 'base64',
'regsense'=>0,
'body' => base64_encode(@file_get_contents($file_name_with_full_path))
);
$timeout=1;
//method post
$fields2 = array(
'key' => $key,
'method' => 'post',
'regsense'=>0, // case sensitive
'file' => $cFile
);
$timeout=1;
//method userrecaptcha
$fields2 = array(
'key' => $key,
'method' => 'userrecaptcha',
'googlekey' => 'DATA_SITE_KEY', //Value of k or data-sitekey parameter you found on page
'pageurl' => 'FULL_URL' // Full URL of the page where you see the ReCaptcha
);
$timeout=5;//for userecaptcha mus set timeout to 5s
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "$api_url/in.php");
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $fields);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($c);
curl_close($c);
echo "<br> result: $result";
if (!preg_match('|OK|', $result)) {
echo '<br>error';
} else {
$id = explode("|", $result)[1];
echo "<br>Captcha id: $id";
}
do {
$info = @file_get_contents($api_url.'/res.php?key=' . $key . '&action=get&id=' . $id);
if ($info == 'CAPCHA_NOT_READY'){
sleep($timeout);
}
} while ($info == 'CAPCHA_NOT_READY');
if (!preg_match('|OK|', $info)) {
echo '<br>error';
} else {
$text = explode('|', $info)[1];
echo "<br>Captcha text: $text";
}
@AZcaptcha

This comment has been minimized.

Owner

AZcaptcha commented Oct 14, 2018

Solving Captchas At $1.8 Per 1000 Recaptcha V2 Solved!
And $0.4 Per 1000 Images Captcha Solved
Unlimited Captcha solver package from $25/month
Please login or register to receive your 100 captcha solver for FREE and integrate our API in your applications.
more at: https://azcaptcha.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment