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
10
votes
5 answers

Laravel Guzzle GET request

$client = new Client(['base_uri' => 'http://api.tvmaze.com/']); $res = $client->request('GET', '/schedule?country=US&date=2014-12-01'); return $res; returns this error: "Class…
johnstones12
  • 113
  • 1
  • 1
  • 5
10
votes
4 answers

3rd party dependency conflict in developing Wordpress Plugin

I am developing a plugin that used composer.. meaning it has a vendor folder inside the plugin folder which includes Guzzle HTTP dependency On wordpress site we installed this plugin, there is an existing plugin that has Guzzle HTTP Now when we…
Joseph Bada
  • 222
  • 2
  • 13
10
votes
2 answers

Guzzle vs ReactPHP vs Amphp for parallel requests

What's the difference between: GuzzleHttp ReactPHP Amphp How they differ and what would be typical use case to use with?
lubosdz
  • 4,210
  • 2
  • 29
  • 43
10
votes
1 answer

Fatal error: Call to undefined method GuzzleHttp\Client::request() with Guzzle 6

I'm using Guzzle 6 with Laravel 5.2. I'm trying to access a simple internal API: use GuzzleHttp\Client; $client = new Client(['base_uri' => getenv('URL_BASE').'api/v1/']); $response = $client->request('GET', 'tournaments'); And I…
Juliatzin
  • 18,455
  • 40
  • 166
  • 325
10
votes
2 answers

Guzzle not sending PSR-7 POST body correctly

It is either not being sent, or not being received correctly. Using curl direct from the command line (using the -d option) or from PHP (using CURLOPT_POSTFIELDS) does work. I start with a PSR-7 request: $request = GuzzleHttp\Psr7\Request('POST',…
Jason
  • 4,411
  • 7
  • 40
  • 53
10
votes
3 answers

How to use proxy authentication with Goutte?

I have the following code but it always returns a 407 HTTP status code. $url = 'http://whatismyip.org'; $client = new Client(); $options = array( 'proxy' => array( 'http' => 'tcp://@x.x.x.x:8010', ), 'auth' =>…
Abs
  • 56,052
  • 101
  • 275
  • 409
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
10
votes
2 answers

Set request options after initialisation in guzzle 6

In Guzzle with version < 6 I used to set my authentication header on the fly after the initialisation of the client. I used setDefaultOption() for this. $client = new Client(['base_url' => $url]); $client->setDefaultOption('auth', [$username,…
tomvo
  • 1,409
  • 1
  • 12
  • 21
10
votes
2 answers

PHP: How to check for timeout exception in Guzzle 4?

Guzzle throws an exception if an error occured during the request. Unfortunately, there does not seem to be an error specific to timeouts - which is important for me as I know that those can ocassionally occur. I'd like to retry the corresponding…
Hirnhamster
  • 7,101
  • 8
  • 43
  • 73
10
votes
1 answer

Converting this cURL for Guzzle

I've tried reading through the Guzzle docs but I can't wrap my head around this problem. I want to use Guzzle instead of cURL for the following: protected $url = 'https://secure.abcdef.com/cgi/xml_request_server.php'; $xml = "\n"; …
Grug
  • 1,870
  • 5
  • 25
  • 38
9
votes
1 answer

How to call API from controller Laravel without using curl and guzzle as its not working

How to call an API from a controller using a helper in laravel without using curl and guzzle because both returing nothing. I have tested in postman the api is working fine but not in laravel. I need to call several API's from different controllers…
Mahendra Pratap
  • 3,174
  • 5
  • 23
  • 45
9
votes
4 answers

posting to endpoint to get the redirect url before purchase

I'm trying to create a custom omnipay driver for a local gateway called creditguard. For this gateway you need to post the data to the endpoint and get back a redirect url for the payment form. My question is how do you post and get the response…
nirz
  • 237
  • 3
  • 8
9
votes
3 answers

Setting up cookies for Guzzle CookieJar

I am doing unit testing in PHP for a site that requires authentication. Authentication is cookie based, so I need to be able to put a cookie like this in the cookie jar: [ 'user_token' =>…
DrDamnit
  • 4,736
  • 4
  • 23
  • 38
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