有没有办法自动拥有一个 Guzzle Service Descriptor 字段,获取一个数组,并将其解析为逗号列表?
数据
Array [ "test", "another test" ]
服务描述符
{
"name": "YouTube",
"baseUrl": "https://www.googleapis.com",
"apiVersion": "v3",
"description": "YouTube GData Graph API",
"operations": {
"GetVideos": {
"httpMethod": "GET",
"uri": "/youtube/v3/videos",
"parameters": {
"id": {
"type":"array",
"location":"query",
"required": true
},
"part": {
"location": "query",
"default": "snippet"
},
"key": {
"location": "query",
"default": "{MY KEY}",
"static": true
},
"maxResults": {
"location": "query",
"default": 50
}
}
}
}
}
该字段是id
under parameters
,我想为其提供原始的 php 字符串数组,并让 Guzzle 自动将其转换为逗号分隔的列表
现在,我必须这样做:
$command = $this->client->getCommand('GetVideos', [
'id' => implode(",", array_slice($this->id, 0, 50))
]);
现在,这会创建一个包含多个 id 实例的 URL
https://www.googleapis.com/youtube/v3/videos?id=test&id=another%20test&part=snippet&key={MY KEY}&maxResults=50
我希望它像这样出来:
https://www.googleapis.com/youtube/v3/videos?id=test,another%20test&part=snippet&key={MY KEY}&maxResults=50
这可能吗?