我希望查询参数可以通过以下方式发送,但不是。
$response=$myObj->myMethod1(new Request('GET', _VER_.'/endpoint', ['query'=>['hello'=>123]]));
public function myMethod1(\GuzzleHttp\Psr7\Request $request):\GuzzleHttp\Psr7\Response {
try {
$response = $this->httpClient->send($request);
} catch (ClientException $e) {
//Deal with exceptions
}
return $response;
}
然后我尝试了这个,他们是:
$response=$myObj->myMethod2(new Request('GET', _VER_.'/endpoint'), ['query'=>['hello'=>123]]);
public function myMethod2(\GuzzleHttp\Psr7\Request $request, $data):\GuzzleHttp\Psr7\Response {
try {
$response = $this->httpClient->send($request, $data);
} catch (ClientException $e) {
//Deal with exceptions
}
return $response;
}
是否无法在Request对象中添加任何参数?