Images download using Goutte Images download using Goutte curl curl

Images download using Goutte


With Goutte 2:

$client = new GuzzleHttp\Client([    'base_url' => 'https://www.google.pl',    'defaults' => [        'cookies' => true,    ]]);$response = $client->post('/login', [    'body' => [        'login'    => $login,        'password' => $password    ]]);$response = $client->get('/images/srpr/logo11w.png');$image = $response->getBody();

With Goutte 1 after adding "guzzle/plugin-cookie": "~3.1" to Composer:

use Guzzle\Http\Client;use Guzzle\Plugin\Cookie\CookiePlugin;use Guzzle\Plugin\Cookie\CookieJar\ArrayCookieJar;$client = new Client('https://www.google.pl');$client->addSubscriber(new CookiePlugin(new ArrayCookieJar()));$response = $client->post('/login', '', array('login' => $login, 'password' => $password))->send();$response = $client->get('/images/srpr/logo11w.png')->send();$image = $response->getBody();