2016-05-31 39 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); 

希望它有幫助!