2016-05-31 45 views
1

我正在使用Guzzle 5.3,看起来它正在更改我的数组参数,删除索引。Guzzle 5.3传递GET数组参数不起作用

这是我的要求:

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

使用用户\历史,请求会:

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

Host:myserver.com

任何人都可以帮忙吗?

回答

1

在github问题上搜索,我发现你可以使用不同的聚合方法。所以我改变我的代码使用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); 

希望它有帮助!