如何将 Guzzle 服务描述中的参数设置为 json 数组?这是我尝试过但不起作用的方法:
$service_description = new Description([
'baseUri' => 'http://api.etrackerplus.com/api',
'operations' => [
'createOrder' => [
'httpMethod' => 'POST',
'uri' => 'api/stores/{store_id}/orders/new.json',
'responseModel' => 'getResponse',
'parameters' => [
'store_id' => [
'type' => 'string',
'location' => 'uri'
],
"order" => [// <== HERE!!!
"location" => "json",
"type" => "array"
]
]
]
],
'models' => [
'getResponse' => [
'type' => 'object',
'additionalProperties' => [
'location' => 'json'
]
]
]
]);
称呼:
$response = $client->createOrder(['store_id' => '23',array( 'order'=>
array("order_number" => "1233"))]);
要发送的 json 正确 json 结构是这样的:
{
"order": {
"order_number": "97221"
}
}