Hi
I have a php function which use captchakiller.com api to solve every captcha
I want to create a youtube account creator using that.
What i want to add to my function :
- use multiple api keys (because one api key = 30 captcha day)
Heres the function :
Thx
I have a php function which use captchakiller.com api to solve every captcha
I want to create a youtube account creator using that.
What i want to add to my function :
- use multiple api keys (because one api key = 30 captcha day)
Heres the function :
PHP:
<?php
//
// Configuration
//
//Your API key
$api_key = 'B63A7848-D7B4-DE7E-E51E-CE1DD506AA78';
//Path to captcha image
$file = getcwd() . '/captcha.jpg';
//Url to CaptchaKiller API
$url = 'http://www.captchakiller.com/api.php';
//
// Functions
//
function upload_captcha($api_key, $file)
{
global $crl;
$postdata = array(
'method' => 'upload_captcha',
'api_key' => $api_key,
'file' => "@$file",
'expire' => '300',
'rights' => 'false'
);
curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($crl);
$headers = curl_getinfo($crl);
if ($headers['header_size'] == 0)
{
curl_close($crl);
die('Upload Transaction failed');
}
else
{
echo 'Successfully uploaded captcha<br />';
}
//Parse captcha ID
$pos = strpos($result, 'SUCCESS: captcha_id=');
$captcha_id = 0;
if($pos !== false)
{
$pattern = '([w-]+)';
$matches = array();
if(preg_match($pattern, substr($result, 20), $matches)) //20 = length of text before the ID
{
$captcha_id = $matches[0];
echo 'Captcha ID: ' . $captcha_id . '<br />';
}
else
{
echo 'Could not find captcha id in: '' . $result . ''<br />';
}
}
else
{
echo $result;
}
return $captcha_id;
}
function get_result($api_key, $captcha_id)
{
global $crl;
//Send request for captcha result
$postdata = array(
'method' => 'get_result',
'api_key' => $api_key,
'captcha_id' => $captcha_id
);
curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($crl);
$headers = curl_getinfo($crl);
if ($headers['header_size'] == 0)
{
curl_close($crl);
die('Get Result transaction failed');
}
return $result;
}
function process_captcha($api_key, $file, $url)
{
$captcha_id = upload_captcha($api_key, $file, $url);
$captcha_result = '';
if($captcha_id != 0)
{
echo 'Getting result';
for($i = 0; $i < 20; $i++)
{
//Wait a few seconds before sending the next request
sleep(5);
//Get the result
$result = get_result($api_key, $captcha_id);
//Parse the result
$pos_success = strpos($result, 'SUCCESS: captcha_result="');
$pos_wait = strpos($result, 'WAIT: check back later');
if($pos_success !== false)
{
$pattern = '(.*)';
$matches = array();
if(preg_match($pattern, substr($result, 25), $matches)) //24 = length of text before the result
{
$captcha_result = substr($matches[0], 0, -1); //Trim off the trailing "
echo '<br />Captcha Result: ' . $captcha_result . '<br />';
}
else
{
echo '<br />Could not find captcha result in: '' . $result . ''<br />';
}
break;
}
else if($pos_wait !== false)
{
//WAIT found, try again
echo '.';
continue;
}
else
{
//FAILURE found
echo '<br />' . $result;
break;
}
if($i == 19)
{
echo '<br />20 attempts have passed and still received WAIT<br />';
}
}
}
return $captcha_result;
}
//
// Main program
//
// Start the cURL session
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $url);
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
$captcha = process_captcha($api_key, $file, $url);
//Close the cURL session
curl_close($crl);
?>