Witam, google zmieniło "formularz" logowania i za nic nie mogę się zalogować przez curla na konto google, na starym formularzu używałem tego kodu:
function getFormFields($data)
{
if (preg_match('/(<form.*?id=.?gaia_loginform.*?<\/form>)/is', $data, $matches)) { $inputs = getInputs($matches[1]);
return $inputs;
} else {
die('didnt find login form'); }
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $COOKIEFILE);
curl_setopt($ch, CURLOPT_COOKIEFILE, $COOKIEFILE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_URL,
'https://accounts.google.com/ServiceLogin?service=youtube&uilel=3&hl=pl&continue=https%3A%2F%2Fwww.youtube.com');
$data = curl_exec($ch);
$formFields = getFormFields($data);
$formFields['identifier'] = $USERNAME;
$formFields['password'] = $PASSWORD;
unset($formFields['PersistentCookie']);
$post_string = http_build_query($formFields);
curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/ServiceLoginAuth');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
Ma ktoś pomysł jak to rozwiązać?
Ten post edytował miras 4.05.2017, 19:08:44