Guzzle 传递多维数组

Guzzle passing multiple dimension array

我的 cURL 请求如下所示:

http://httpbin.org/post -d '{"multifilter":{"limit":5}}'

我的 Guzzle 代码:

$request = $client->createRequest('POST', 'http://httpbin.org/post');
$postBody = $request->getBody();
$postBody->setField('multifilter', array("limit"=>"5"));
$response = $client->send($request);

这一行

$postBody->setField('multifilter', array("limit"=>"5"));

不正确,但是如何将变量设置为数组?

或者可能存在要添加 json 查询的内容?我的意思是 addJsonquery('multifilter":{"limit":5}}') ?

解决方案是将 json 添加到 body

$request = $client->createRequest('POST', $url, [
        'body' => $json,
]);
$response = $client->send($request);

在github中回答:

github.com/guzzle/guzzle/issues/1027