I'm trying to do a curl to use a private webpage after the login, the login form call an action to http://www.website.com/entrar/sair/ with the post vars - login, senha(password), lembrar(remember - cookies), g-recaptcha-response (captcha system) and logar. After a sucessful login the page is redirected to http://www.website.com/private (the page I want to use). The problem is that I dont know what to do with captcha, after I get a sucessful login I get a cookie that is valid for next 24 hours. So what I need to do is, when I access http://localhost/index.php, it will show the page http://www.website.com/private, if the cookie has expired, it will show the anti captcha from http://www.website.com/entrar/sair/, so I can do a manual verification and get another cookie valid for 24 hours.
The code I did so far:
$path = $_SERVER["DOCUMENT_ROOT"]."/teste/ctemp";
$url="http://website.com/entrar/sair/";
$postinfo = "login=xxx&senha=xxx&g-recaptcha-response=xxxx&lembrar=on&logar=";
$website="http://website.com/private";
$cookie_file_path = $path."/cookie.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
curl_setopt($ch, CURLOPT_USERAGENT,
"Mozilla/5.0 (Windows; U; Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
curl_exec($ch);
//page with the content I want to grab
curl_setopt($ch, CURLOPT_URL, $website);
$html = curl_exec($ch);
curl_close($ch);
echo $html;
Post debug: [ATTACH=CONFIG]5317[/ATTACH]
z0DxBme.png