Pass parameters using the guzzle client

3

I need to consume an api, passing the parameters are done this way:

  

link

I'm using guzzle to make the request.

I am instantiating the client with the url base of this form:

$client = new Client(['base_url' => 'https://api.typeform.com/v1']);

I wanted to pass the parameters "/form" , "[typeform_UID]?key=[your_API_key]" , using $client->get() . If I use get(query=>[]) of guzzle it does not form the url the way I would like it.

Does anyone know of any way to do this by using Client with base_url ?

    
asked by anonymous 28.09.2016 / 14:52

1 answer

2

The way to set the default parameter in Guzzle is by using query .

See:

$client = new GuzzleHttp\Client([
    'base_uri' => 'http://example.com/',
    'query'   => ['foo' => 'bar']
]);

If you need to use other parameters in the url combined with the default parameters you want to define, I suggest using the Client::getConfig('query') method, matching the new desired values, like this:

28.09.2016 / 14:57