Guzzle 6 PSR7 Request: How to send custom headers, body and cookies

You may also like...

3 Responses

  1. Gabrieli says:

    Thank you!
    I was looking for this a few days, you saved med. Good post, really helpful!

  2. Kyle says:

    Good Post!
    How do I send a cookie jar var with this code?

    $request = new GuzzleHttp\Psr7\Request($params[“type”], $url, $headers, $body);
    $response = $client->send($request);

    Put it directly in headers? Because its not working.

    • abir says:

      Hi Kyle,
      You can send your custom cookie jar with the send function:

      $request = new GuzzleHttp\Psr7\Request($params["type"], $url, $headers, $body);
      $response = $client->send($request, ["cookies" => $cookie_jar]);

Leave a Reply

%d bloggers like this: