Не получается авторизоваться на сайте с помощью guzzlehttp
.
Получаю ошибку:
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST https://python.su/account/signin/
resulted in a403 FORBIDDEN
response:
При включенном дебаге:
Warning: curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE*
Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error
Код:
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
$client = new Client([
'base_uri' => 'https://python.su',
'allow_redirects' => true,
'headers' => [
'User-Agent' => 'Mozilla/5.0 (Linux 3.4; rv:64.0) Gecko/20100101 Firefox/15.0',
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Content-Type' => 'application/x-www-form-urlencoded'
]
]);
$login = $client -> request('POST','/account/signin/',[
'form_params' => [
'backurl' => '/',
'email' => 'llogin',
'password' => 'ppasword',
],
'debug' => false
]);
$cookie = $login -> getHeaderLine('Set-Cookie');
$discounts = $client -> request('GET','/',[
'headers' => [
'Cookie' => $cookie
]
]);
$body = $discounts -> getBody() -> getContents();
echo $body;