Skip to content

Instantly share code, notes, and snippets.

@AZcaptcha
Last active January 27, 2021 16:52
Show Gist options
  • Save AZcaptcha/041555ba000acb54b635650f89422ef5 to your computer and use it in GitHub Desktop.
Save AZcaptcha/041555ba000acb54b635650f89422ef5 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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