guzzle6

Guzzle 6 progress of download

回眸只為那壹抹淺笑 提交于 2019-11-27 14:49:32
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 an event dispatcher. I tried the on_stats , but the callback is only fired at the end. The progress subscriber plugin is deprecated https://github.com/guzzle/progress-subscriber I'm testing the following code. $dl = 'http://archive.ubuntu.com/ubuntu/dists/wily/main/installer-amd64/current/images/netboot/mini.iso'; $client = new Client([]); $request

How do you log all API calls using Guzzle 6

百般思念 提交于 2019-11-27 14:04:19
I'm trying to use guzzle 6 which works fine but I'm lost when it comes to how to log all the api calls. I would like to simply log timing, logged in user from session, url and any other usual pertinent info that has to do with the API call. I can't seem to find any documentation for Guzzle 6 that refers to this, only guzzle 3 (Where they've changed the logging addSubscriber call). This is how my current API calls are: $client = new GuzzleHttp\Client(['defaults' => ['verify' => false]]); $res = $client->get($this->url . '/api/details', ['form_params' => ['file' => $file_id]]); You can use any

Upload file using Guzzle 6 to API endpoint

余生颓废 提交于 2019-11-27 02:06:14
问题 I am able to upload a file to an API endpoint using Postman. I am trying to translate that into uploading a file from a form, uploading it using Laravel and posting to the endpoint using Guzzle 6. Screenshot of how it looks in Postman (I purposely left out the POST URL) Below is the text it generates when you click the "Generate Code" link in POSTMAN: POST /api/file-submissions HTTP/1.1 Host: strippedhostname.com Authorization: Basic 340r9iu34ontoeioir Cache-Control: no-cache Postman-Token:

How do you log all API calls using Guzzle 6

我的梦境 提交于 2019-11-26 16:35:10
问题 I'm trying to use guzzle 6 which works fine but I'm lost when it comes to how to log all the api calls. I would like to simply log timing, logged in user from session, url and any other usual pertinent info that has to do with the API call. I can't seem to find any documentation for Guzzle 6 that refers to this, only guzzle 3 (Where they've changed the logging addSubscriber call). This is how my current API calls are: $client = new GuzzleHttp\Client(['defaults' => ['verify' => false]]); $res

Guzzlehttp - How get the body of a response from Guzzle 6?

爷,独闯天下 提交于 2019-11-26 15:06:23
I'm trying to write a wrapper around an api my company is developing. It's restful, and using Postman I can send a post request to an endpoint like http://subdomain.dev.myapi.com/api/v1/auth/ with a username and password as POST data and I am given back a token. All works as expected. Now, when I try and do the same from PHP I get back a GuzzleHttp\Psr7\Response object, but can't seem to find the token anywhere inside it as I did with the Postman request. The relevant code looks like: $client = new Client(['base_uri' => 'http://companysub.dev.myapi.com/']); $response = $client->post('api/v1