【发布时间】:2020-02-27 19:47:49
【问题描述】:
我正在尝试按以下格式发出 API 请求:
/api/v1/courses?enrollment_state=active&include[]=total_students&include[]=term
如何使用HttpClient 组件查询字符串参数来做到这一点?
$response = $client->request('GET', '/api/v1/courses', [
'query' => [
'enrollment_state' => 'active',
'include[]' => 'term',
'include[]' => 'total_students',
],
]);
由于重复的数组键,上述方法不起作用?
我也试过了:
'include[]' => ['term', 'total_students']
【问题讨论】:
-
您是否尝试过仅使用一个“包含”键并在数组中传递“学期”和“总学生”?
标签: php symfony symfony4 symfony-http-client