Questions tagged [guzzle]

Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. Guzzle can be used with cURL, PHP's stream wrapper, sockets, and non-blocking libraries like React.

Guzzle is a PHP HTTP client & framework for building RESTful web service clients.


Features:

  • Extremely powerful API provides all the power of cURL with a simple interface.
  • Truly take advantage of HTTP/1.1 with persistent connections, connection pooling, and parallel requests.
  • Service description DSL allows you build awesome web service clients faster.
  • Symfony 2 event-based plugin system allows you to completely modify the behavior of a request.
  • Includes a custom Node.js web server to test your clients. Unit-tested with PHPUnit with 100% code coverage.

Documentation:

2576 questions
22
votes
1 answer

Guzzle difference between 'connect_timeout' and 'timeout'

What's the difference between 'connect_timeout' and 'timeout' request options in Guzzle.
Tshwarelo
  • 375
  • 4
  • 9
22
votes
5 answers

Limit connecting time with Guzzle HTTP PHP client

I'm using Guzzle to open a list of url-s and get the headers. Some of the urls are taking too long to respond and can't be openned and i want to ignore them. It takes me up to 20+ seconds before Guzzle throws an exception and i want to change this…
user3147578
  • 221
  • 1
  • 2
  • 3
20
votes
6 answers

Proper way to send (POST) xml with guzzle 6

I want to perform a post with guzzle sending an xml file. I did not find an example. What I 've done so far is : $xml2=simplexml_load_string($xml) or die("Error: Cannot create object"); use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; $client…
user3485417
  • 583
  • 2
  • 7
  • 21
20
votes
3 answers

Copy remote file using Guzzle

I'm trying to copy a remote file (image PNG, GIF, JPG ...) to my server. I use Guzzle since I sometimes get 404 with copy() even if the file exists and I also need to do a basic auth. This script is within a long script launched in command triggered…
Spir
  • 1,709
  • 1
  • 16
  • 27
19
votes
5 answers

Guzzle ~6.0 multipart and form_params

I am trying to upload file and send post parameters at the same time like this: $response = $client->post('http://example.com/api', [ 'form_params' => [ 'name' => 'Example name', ], 'multipart' => [ [ 'name' …
Jordan Dobrev
  • 317
  • 1
  • 3
  • 10
18
votes
3 answers

How do we specify TLS/SSL options in Guzzle?

We are starting to use Guzzle in PHP with code which calls a variety of different APIs, a few of which don't support TLSv1.2 and some of which require TLSv1.2. What's the best way to force Guzzle to use the most recent protocol available, except in…
MattC
  • 313
  • 1
  • 3
  • 8
17
votes
1 answer

Passing client certificates through Curl request using Guzzle

I have the following curl command sudo curl -E openyes.crt.pem --key openyes.key.pem https://sky.myapitutorial.in:444/app/live/get which works fine. But when I am trying to do from Guzzle, its failing. I am unable to pass the client certificates in…
Ajeesh
  • 5,650
  • 8
  • 30
  • 52
17
votes
4 answers

Queuing Guzzle Requests With Limits

I'm working on a Laravel application, using Guzzle 6. A lot of functionality relies on an API, of which I've created a wrapper for. My wrapper's a single class, that creates the Guzzle client in the __construct(), and has a variety of public…
Daniel Dewhurst
  • 2,533
  • 2
  • 21
  • 39
17
votes
2 answers

How does Guzzle send async web requests?

cURL is synchronous. So how do libraries like Guzzle send asynchronous web requests?
Code
  • 6,041
  • 4
  • 35
  • 75
17
votes
6 answers

Set proxy in Guzzle

I have a problem with set proxy in guzzle that a blank page was shown while with curl everything works perfect. The code that I used in guzzle and curl came below. What is wrong with this code: Guzzle: use GuzzleHttp\Client; use…
M Sh
  • 429
  • 2
  • 4
  • 11
17
votes
1 answer

base_uri not being based from guzzle client instantiation

I'm using lumen trying to set up simple API requests via guzzle. The problem is the base_uri parameter doesn't appear to be passed correctly on the initial new Client(). Simplified example: use GuzzleHttp\Client; $client = new Client([ 'base_uri'…
drrobotnik
  • 739
  • 1
  • 11
  • 25
17
votes
4 answers

Not getting expected response from Guzzle

I'm trying to build an endpoint that forwards the data passed to it to an API using the Slim PHP Framework and I'm having trouble getting my response from a Guzzle request. $app->map( '/api_call/:method', function( $method ) use( $app ){ $client…
Johnathan Barrett
  • 546
  • 2
  • 7
  • 24
17
votes
4 answers

Symfony2 ReST Client Structure

I am trying to establish a best-practice pattern for ReST clients in Symfony 2, as this is a very common job for us at my company, where we have Symfony apps on the frontend edge talking to Java based backends over HTTP/ReST. My thinking is this,…
16
votes
3 answers

Guzzle 6 download file

Need help using Guzzle 6 for downloading a file from a rest API. I don't want the file to be saved locally but downloaded from web browser. Code so far below, but believe I am missing something?
Kevin Lindmark
  • 1,155
  • 3
  • 13
  • 26
16
votes
3 answers

Error logging is truncated in Laravel of Guzzle http

Guzzle http is truncating exceptions with more than 120 characters, but I need to log the full exception message. How can I do this? I am using laravel 4.2.22.
Parvez Alam
  • 358
  • 1
  • 3
  • 13