NewtonWagner
NewtonWagner

Reputation: 21

Guzzle 5.3 Passing GET array parameters not working

I'm using Guzzle 5.3, and looks like it is changing my array parameters, removing indexes.

This is my request:

$request = $client->createRequest(
    'GET',
    'http://myserver.com/file.php?param=1&arrayparam[10]=2015&arrayparam[18]=2016'
);
$response = $client->send($request);

Using the Subscriber\History, the Request is going:

GET /file.php?param=1&arrayparam=2015&arrayparam=2016 HTTP/1.1

Host: myserver.com

Can anyone help on this?

Upvotes: 1

Views: 393

Answers (1)

NewtonWagner
NewtonWagner

Reputation: 21

Searching on github issues, I found that you can use different aggregate methods. So I changed my code to use phpAggregator():

$request = $client->createRequest(
    'GET',
    'http://myserver.com/file.php?param=1&arrayparam[10]=2015&arrayparam[18]=2016'
);
$request->getQuery()->setAggregator(Query::phpAggregator());
$response = $client->send($request);

Hope it helps!

Upvotes: 1

Related Questions