как я могу исправить этот логин с помощью curl - PullRequest
0 голосов
/ 24 мая 2019

Я пытаюсь зайти на этот сайт с помощью curl, но это не сработало когда я изменяю URL-адрес curl_get внизу на тот же URL-адрес сообщения curl, тогда я вижу страницу входа в систему, и когда я меняю ее на другую страницу, я получаю сообщение об ошибке. Так как я могу войти с помощью curl? Эта информация (адрес электронной почты и пароль) является реальной учетной записью, поэтому вы можете проверить ее напрямую.

<?php

define('USERNAME', 'anmeldungtest@hotmail.com');
define('PASSWORD', 'lolo2019');
define('SUBMIT', 'sign in');
define('USER_AGENT', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0');
define('COOKIE_FILE', 'C:\xampp\cookies.txt');//Where our cookie information will be stored (needed for authentication).
define('LOGIN_FORM_URL', 'https://app.pipedrive.com/auth/login');
define('LOGIN_ACTION_URL', 'https://app.pipedrive.com/auth/login');//Login action URL. Sometimes, this is the same URL as the login form.


$postValues = array(
    'login' => USERNAME,
    'password' => PASSWORD
);


$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, LOGIN_ACTION_URL);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postValues));
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);//We don't want any HTTPS errors.
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_COOKIEJAR, COOKIE_FILE);//Where our cookie details are saved. This is typically required for authentication, as the session ID is usually saved in the cookie file.
curl_setopt($curl, CURLOPT_USERAGENT, USER_AGENT);//Sets the user agent. Some websites will attempt to block bot user agents. Hence the reason I gave it a Chrome user agent.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);//Tells cURL to return the output once the request has been executed.
curl_setopt($curl, CURLOPT_REFERER, LOGIN_FORM_URL);//Allows us to set the referer header. In this particular case, we are fooling the server into thinking that we were referred by the login form.
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); //Do we want to follow any redirects?
curl_exec($curl);


if(curl_errno($curl)){
    throw new Exception(curl_error($curl));
}

//CURL GET url

//curl_setopt($curl, CURLOPT_URL, 'https://kad-fa7a1e.pipedrive.com/pipeline');
curl_setopt($curl, CURLOPT_URL, 'https://app.pipedrive.com/auth/login');
curl_setopt($curl, CURLOPT_COOKIEJAR, COOKIE_FILE);
curl_setopt($curl, CURLOPT_USERAGENT, USER_AGENT);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);


echo curl_exec($curl);
...