DJIGIT95
New member
I am trying to solve recaptcha V2 with API 2captcha ,
I am using this code:
Why am I sometimes not getting a response?
I am trying to make condition with a timeout here.
Then I want to loop all the code every 2 min 30 secs.
How can I use condition with
How to do loop the code every 2 min 30 secs?
I am using this code:
Code:
<?php
function token(){
$apiKey = "MY_API_KEY";
$googleKey = "6LfBixYUAAAAABhdHynFUIMA_sa4s-XsJvnjtgB0";
$pageUrl = "https://example.com/";
$time = time();
while ( true ) {
$retrieve= file_get_contents("http://2captcha.com/in.php?key=".$apiKey."&method=userrecaptcha&googlekey=".$googleKey."&pageurl=".$pageUrl, false, $ctx);
$first = array($retrieve);
$result = explode('OK|',$first[0]);
$hello = $result[1];
$con="http://2captcha.com/res.php?key=".$apiKey."&action=get&id=".$hello;
sleep(23);
$getting = file_get_contents($con);
$second = array($getting);
$secondresult = explode('OK|',$second[0]);
$reponsetoken = $secondresult[1];
echo'<br/>';
echo'<br/>';
echo'get new captcha token ...';
echo'<br/>';
echo'<br/>';
if ((time() - $time) >= 99) {
echo date("Y:m:d g:i:s"), PHP_EOL;
$time = time();
}
sleep(2);
}
}
if (!empty($reponsetoken)) {
file_put_contents( 'token.txt', $reponsetoken );
} else{token();}
?>
Why am I sometimes not getting a response?
I am trying to make condition with a timeout here.
$retrieve= file_get_contents("http://2captcha.com/in.php?key=".$apiKey."&method=userrecaptcha&googlekey=".$googleKey."&pageurl=".$pageUrl, false, $ctx);
Then I want to loop all the code every 2 min 30 secs.
How can I use condition with
file_get_contents()
?How to do loop the code every 2 min 30 secs?