Questions tagged [guzzle6]

337 questions
13
votes
2 answers

Passing cookies from browser to Guzzle 6 client

I have a PHP webapp that makes requests to another PHP API. I use Guzzle to make the http requests, passing the $_COOKIES array to $options['cookies']. I do this because the API uses the same Laravel session as the frontend application. I recently…
Thelonias
  • 2,918
  • 3
  • 29
  • 63
11
votes
5 answers

Guzzle 6 - Get request total time

I'm searching to retrieve the request total time in Guzzle 6, just after a simple GET request : $client = new GuzzleHttp\Client(); $response = client->get('http://www.google.com/'); But can't find anything in the docs about that. Any idea ? Thanks…
Benoth
  • 111
  • 1
  • 1
  • 3
11
votes
1 answer

How to make create batch request in Guzzle6?

I need to send multiple requests so I want to implement a batch request. How can we do it in Guzzle6? Using the the old way: $client->send(array( $client->get($courses), //api url $client->get($job_categories), //api url )); is giving me…
RahulG
  • 1,028
  • 1
  • 15
  • 27
10
votes
3 answers

How can I get Guzzle 6 to retry a request upon a 503 error in Laravel

I've written some code in Laravel 5.2 to retrieve results from an unrelible API source. However, it needs to be able to automatically retry the request on failed attempts, as the API call results in a 503 about a third of the time. I'm use Guzzle to…
ZeroGodForce
  • 143
  • 1
  • 2
  • 6
10
votes
2 answers

What's the best way to get the duration of an API call using Guzzle 6

Currently with Guzzle 6 it seems there's no out of the box way to get the duration of an API call. What's the best way to get this stat with any ordinary call using the code below. I'm using the following code from How do you log all API calls using…
KingKongFrog
  • 13,946
  • 21
  • 75
  • 124
9
votes
2 answers

Guzzle 6 - Promises - Catching Exceptions

I don't really understand how to catch an exception (forward it) within the onReject handler. I was wondering if anyone can point me in the right direction on how to successfully do so. I'm sending in some async requests and when one fails with "An…
Fermier
  • 91
  • 1
  • 3
9
votes
2 answers

Guzzle get file and forward it

I have a web-service that gets a file and returns it to the user (based on Symfony). Ever since I used curl to do this. I just found guzzlehttp and it seems great. However, I do not know how to do this with guzzle without saving the downloaded…
Robin
  • 3,512
  • 10
  • 39
  • 73
9
votes
2 answers

How can I asynchronously download files with Guzzle 6?

I am trying to asynchronously download files with Guzzle 6, but the documentation seems vague and couldn't find any useful examples. The thing I am not sure about is - how am I supposed to save the received data? Currently I am doing it like…
M. Ivanov
  • 283
  • 1
  • 2
  • 13
8
votes
1 answer

PHP: Guzzle 6 + Guzzle-cache-middleware

I've a page doing some REST queries using Guzzle 6. It works fine, however sometimes it gets too slow because it's always making queries. I found out that there is guzzle-cache-middleware that is supposed to cache responses from the remote…
TCB13
  • 3,067
  • 2
  • 39
  • 68
8
votes
1 answer

Guzzle 6 progress of download

I want to download a large file with Guzzle and want to track the progress. I don't know if I have to pass a stream or use the RequestMediator somehow. I tried with subscribing to the event curl.callback.progress, but the PSR 7 Request doesn't have…
Laoneo
  • 1,546
  • 1
  • 18
  • 25
8
votes
2 answers

How to mock responses for specific URLs with Guzzle?

The Guzzle 6 documentation gives an easy way to mock HTTP calls so that each request returns a specific response : http://docs.guzzlephp.org/en/latest/testing.html#mock-handler However, as it is stated in the documentation, the MockHandler defines a…
Michaël Perrin
  • 5,903
  • 5
  • 40
  • 65
7
votes
1 answer

PHP - JWT get token wrong number of segments

I need consume a API using JWT, for this, I'm build a API client from PHP with using Guzzle and Firebase PHP-JWT The documentation of API say: Prepare and post a JWT for authorization. Endpoint URL: https://api.example.com/auth The JWT has three…
Alejandro
  • 809
  • 1
  • 10
  • 21
7
votes
4 answers

PHP: Guzzle 6 - cURL error 7 Connection Refused

I've searched and searched, and read the documentation at http://docs.guzzlephp.org/en/stable/request-options.html and confirmed the error at https://curl.haxx.se/libcurl/c/libcurl-errors.html and for the life of me, I cannot figure out what's going…
TomJ
  • 310
  • 1
  • 2
  • 19
7
votes
3 answers

Object of class GuzzleHttp\Psr7\Request could not be converted to string

I've got an issue for laravel 5.4 when I trying to using guzzleHttp. here is my code. use GuzzleHttp\Client; $url = 'http://example.com'; $client = new Client(); $parameter = ['query' => ['name' => 'xxx', 'address' => 'yyy'], 'headers' => […
PHP Java Eng
  • 81
  • 1
  • 1
  • 5
7
votes
2 answers

Mock response and use history middleware at the same time in Guzzle

Is there any way to mock response and request in Guzzle? I have a class which sends some request and I want to test. In Guzzle doc I found a way how can I mock response and request separately. But how can I combine them? Because, If use history…
xAoc
  • 3,448
  • 3
  • 23
  • 36
1
2
3
22 23