zifanchuck
15.09.2009, 22:50
у меня какието траблы с антикаптчей. пишет ERROR_WRONG_USER_KEY хотя кей верный и в админке вижу капчу... тоисть ее разгадывают но мне пишет
ID ХХХХХХХХХ
sleep 3 server returned error: ERROR_WRONG_USER_KEY
ето только у меня?
самый обычный пример скрипта...
<?php
function recognize($filename, $apikey, $is_verbose = true, $rtimeout = 3, $mtimeout = 200, $is_phrase = 0, $is_regsense = 1, $is_numeric = 0, $min_len = 0, $max_len = 0)
{
if (!file_exists($filename))
{
if ($is_verbose) echo "file $filename not found\n";
return false;
}
$postdata = array(
'method' => 'post',
'key' => $apikey,
'file' => '@'.$filename, //полный путь к файлу
'phrase' => $is_phrase,
'regsense' => $is_regsense,
'numeric' => $is_numeric,
'min_len' => $min_len,
'max_len' => $max_len,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ac-service.info/in.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($ch);
if (curl_errno($ch))
{
if ($is_verbose) echo "CURL returned error: ".curl_error($ch)."\n";
return false;
}
curl_close($ch);
if (strpos($result, "ERROR")!==false)
{
if ($is_verbose) echo "server returned error: $result\n";
return false;
}
else
{
$ex = explode("|", $result);
$captcha_id = $ex[1];
if ($is_verbose) echo "ID $captcha_id \n";
$waittime = 0;
if ($is_verbose) echo "<br>sleep $rtimeout \n";
sleep($rtimeout);
while(true)
{
$result = file_get_contents('http://ac-service.info/res.php?key=$ackey&action=get&id='.$captcha_id);
if (strpos($result, 'ERROR')!==false)
{
if ($is_verbose) echo "server returned error: $result\n";
return false;
}
if ($result=="CAPCHA_NOT_READY")
{
if ($is_verbose) echo "<br>captcha is not ready yet\n";
$waittime += $rtimeout;
if ($waittime>$mtimeout)
{
if ($is_verbose) echo "<br>timelimit ($mtimeout) hit\n";
break;
}
if ($is_verbose) echo "<br>waiting for $rtimeout seconds\n";
sleep($rtimeout);
}
else
{
$ex = explode('|', $result);
if (trim($ex[0])=='OK') return trim($ex[1]);
echo '<br>'.$ex[1];
}
}
return false;
}
}
$captcha=recognize('Z:/home/localhost/www/cap.jpg' ,'XXXXXXXXXXXXXXXXXXXXXX', true);
?>
может чтото не так? пробовал и на хостинге таже трабла
ID ХХХХХХХХХ
sleep 3 server returned error: ERROR_WRONG_USER_KEY
ето только у меня?
самый обычный пример скрипта...
<?php
function recognize($filename, $apikey, $is_verbose = true, $rtimeout = 3, $mtimeout = 200, $is_phrase = 0, $is_regsense = 1, $is_numeric = 0, $min_len = 0, $max_len = 0)
{
if (!file_exists($filename))
{
if ($is_verbose) echo "file $filename not found\n";
return false;
}
$postdata = array(
'method' => 'post',
'key' => $apikey,
'file' => '@'.$filename, //полный путь к файлу
'phrase' => $is_phrase,
'regsense' => $is_regsense,
'numeric' => $is_numeric,
'min_len' => $min_len,
'max_len' => $max_len,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ac-service.info/in.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($ch);
if (curl_errno($ch))
{
if ($is_verbose) echo "CURL returned error: ".curl_error($ch)."\n";
return false;
}
curl_close($ch);
if (strpos($result, "ERROR")!==false)
{
if ($is_verbose) echo "server returned error: $result\n";
return false;
}
else
{
$ex = explode("|", $result);
$captcha_id = $ex[1];
if ($is_verbose) echo "ID $captcha_id \n";
$waittime = 0;
if ($is_verbose) echo "<br>sleep $rtimeout \n";
sleep($rtimeout);
while(true)
{
$result = file_get_contents('http://ac-service.info/res.php?key=$ackey&action=get&id='.$captcha_id);
if (strpos($result, 'ERROR')!==false)
{
if ($is_verbose) echo "server returned error: $result\n";
return false;
}
if ($result=="CAPCHA_NOT_READY")
{
if ($is_verbose) echo "<br>captcha is not ready yet\n";
$waittime += $rtimeout;
if ($waittime>$mtimeout)
{
if ($is_verbose) echo "<br>timelimit ($mtimeout) hit\n";
break;
}
if ($is_verbose) echo "<br>waiting for $rtimeout seconds\n";
sleep($rtimeout);
}
else
{
$ex = explode('|', $result);
if (trim($ex[0])=='OK') return trim($ex[1]);
echo '<br>'.$ex[1];
}
}
return false;
}
}
$captcha=recognize('Z:/home/localhost/www/cap.jpg' ,'XXXXXXXXXXXXXXXXXXXXXX', true);
?>
может чтото не так? пробовал и на хостинге таже трабла