Using "guzzlehttp/guzzle": "^6.3", how can I convert a URL including query parameters to a syntax where an options array is used?
$exampleUrl = http://A001234/datadownload/test?reference=abc&opt_responseformat=json&opt_servicemode=async
Pasting this in browser or POSTMAN gives me a nice little JSON stump back. But I have not been able to use this with an options array. Here is some code, that I tried:
$client = new GuzzleHttp\Client([
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
],
'verify' => false
]);
$result = $client->request('GET', 'http://A001234/datadownload/test', [
"form_params" => [
"opt_responseformat" => "json",
"opt_servicemode"=> "async"
]
]);
if($result->getStatusCode() == 200) {
dd(json_decode($result->getBody())); // dumps null expecting json object
}
Any ideas what I am missing?