guzzle

How do I make a guzzle response into a response to a request from a client?

对着背影说爱祢 提交于 2019-12-11 19:46:05
问题 I have an application running on webserver A. I have a second application running on webserver B. Both webservers require a login. What I need to do is have a request to webserver A pass through to webserver B and return a file to the client without having the client login to Webserver B. (In other words, webserver B will be invisible to the client and I will take care of the auth credentials with my request to B from A). The code below is built on a laravel framework, but I don't believe the

guzzle on azure to get all virtual hosts

三世轮回 提交于 2019-12-11 18:27:41
问题 I have working code on Postman and I can get all virtual hosts, but when Im doing on the PHP with Guzzle it gives me trouble. First part of code I get it where I get bearer token, but then to get list of virtual hosts it gives me error. here is my code $client = new \GuzzleHttp\Client(); $res = $client->request( 'POST', "https://login.microsoftonline.com/".$tenant_id."/oauth2/token", Array( 'form_params' => Array( 'grant_type' => 'client_credentials', 'client_id' => $client_id, 'client_secret

cURL error 7: Failed to connect to maps.googleapis.com port 443

我们两清 提交于 2019-12-11 14:42:20
问题 I got following Error when get Distance between two places in Laravel. i use guzzlehttp/guzzle package to get Google Map api response. i previously declare use GuzzleHttp\Client; How to solve this Issue. Error : cURL error 7: Failed to connect to maps.googleapis.com port 443: Network is unreachable (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) $pickupaddress = urlencode($frmplace); $deliveryaddress = urlencode($destplace); $client = new GuzzleHttp\Client(); $disrequest = $client-

Guzzle HTTP request transforms from POST to GET

不打扰是莪最后的温柔 提交于 2019-12-11 11:19:59
问题 I have this very weird thing going on when trying to make post to an external API, I try to make a POST request to the URL but Guzzle make a GET request instead (which is a legal action on this API but returns something different). Here is the code: $request = $this->client->createRequest('POST', 'sessions', [ 'json' => [ 'agent_id' => $agentId, 'url' => $url ], 'query' => [ 'api_key' => $this->apiKey ] ]); echo $request->getMethod(); // comes out as POST $response = $this->client->send(

Guzzle 5.3 - Get request duration for asynchronous requests

点点圈 提交于 2019-12-11 11:12:33
问题 I am timing synchronous requests as suggested here: guzzle-6-get-request-total-time But I also have a guzzle pool with two or more requests that get batch-executed asynchronously. I need to retrieve the duration each request took to return. I am certain there is a simple way to retrieve this information that I am just overlooking. The infos are in the underlying curl, I am just unsure how to get to them. 回答1: Turns out, by listening to the complete event, one can catch the entire transferinfo

PHP Guzzle. How to set custom boundary to the multipart POST request?

旧巷老猫 提交于 2019-12-11 11:08:39
问题 How can I set custom boundary to the multipart POST request? Following request options configuration doesn't work. 'headers' => ['Content-Type' => 'multipart/form-data; boundary=CUSTOM_BOUNDARY'] 回答1: Guzzle uses psr7 to combine multipart form fields into request body. The most correct way to deal with custom boundary would be using GuzzleHttp\Psr7\MultipartStream . $boundary = 'my_custom_boundary'; $multipart_form = [ [ 'name' => 'upload_id', 'contents' => $upload_id, ], [ 'name' => '_uuid',

How to parse SimpleXMLElement in php / Laravel 5?

梦想与她 提交于 2019-12-11 01:44:21
问题 I use Guzzle to make an XML request to an external API in the back-end. This is where I create the Guzzle client: $client = new Client(); //GuzzleHttp\Client This is where I make the request: $request = $client->request( 'GET', 'This is where I put the URL'); This is where I get the Guzzle response and try to parse it: $xml = $request->getBody()->getContents(); $xml = new \SimpleXMLElement($xml); $xml = simplexml_load_string($xml); If I do this: dd($xml); I receive this in return:

Sending data with put / post to a webservice in Laravel

落花浮王杯 提交于 2019-12-10 21:48:03
问题 I'm trying to create a dynamic method to send / receive my data with my webservice using guzzle and laravel I have the following structure in my controller class TipoProjetoController extends Controller { private $Tabela = 'tipoprojeto'; public function AppWebService($Who, $Type, $Data) { $Client = new Client(['base_uri' => config('constants.caminhoWS').$Who]); $response = $Client->request($Type, $Data); return $response->getBody()->getContents(); } public function index() { $Dados = $this-

PHP Guzzle 5: Cannot handle URL with PORT number in it

余生颓废 提交于 2019-12-10 21:42:10
问题 I am using the latest version of guzzle. (from composer.json) "guzzlehttp/guzzle": "~5" (from composer.lock) "name": "guzzlehttp/guzzle", "version": "5.2.0", When I attempt to request (GET or POST) with a URL that contains a PORT number: $response = $client->get('http://www.hostdnshere.com:8888', array()); I get the following error: string(68) "cURL error 7: Failed to connect to 000.000.000.000: Permission denied" When I do the same but omit the PORT: $response = $client->get('http://www

What is exactly “concurrency” in Guzzle?

大憨熊 提交于 2019-12-10 19:07:01
问题 I have not found much information about concurrency option in Pool . If this is a number of TCP sockets which could be opened on server, then the question is "What number of concurrency could I use in order to handle requests quicker?". I have this example of using Pool : // I am using Laravel, this is basically retrieving entities from DB $exchangers = Exchanger::all(); $client = new Guzzlelient(); $requests = []; foreach ($exchangers as $exchanger) { $requests[$exchanger->id] = new Request(