Php Guzzle form_参数不接受数组

Php Guzzle form_参数不接受数组,php,guzzle,guzzle6,Php,Guzzle,Guzzle6,我使用的是Guzzle 6,无法在客户端主体中传递带有form_参数的数组 $postFields = [ form_params => [ 'data[test]' => "TEST", 'data[whatever]' => "Whatever..." ] ]; $client = new GuzzleClient([ 'cookies' => $jar, // The cookie '

我使用的是Guzzle 6,无法在客户端主体中传递带有form_参数的数组

$postFields = [
    form_params => [
        'data[test]' => "TEST",
        'data[whatever]' => "Whatever..."
    ]
];

$client = new GuzzleClient([
        'cookies' => $jar, // The cookie
        'allow_redirects' => true, // Max 5 Redirects
        'base_uri' => $this->navigateUrl, // Base Uri
        'headers' => $this->headers
]);
$response = $client->post('api',[$postFields]);
最后,当我发送请求时,我的数据不见了。。。但是如果我在响应中手动添加数据,它就可以正常工作

$response = $client->post(
    'api',
    [form_params => [
        'data[test]'=>"TEST",
        'data[wht]' => 'Whatever'
    ],
]
// It's working this way...

我希望我足够清楚,如果你需要更多的信息,请随时询问。提前谢谢。

我看到一些问题。首先是,
$postFields
数组的格式似乎不正确,其次是将$postFields数组包装到另一个数组中

$options = [
    'debug' => true,
    'form_params' => [
        'test' => 15,
        'id' => 43252435243654352,
        'name' => 'this is a random name',
    ],
    'on_stats' => $someCallableItem,
];
$response = $client->post('api', $options);