I'm building an application in Laravel 5.5 where I'm calling an api request to get response, I've following in my controller:
$client = new GuzzleHttp\Client();
$response = $client->request('GET', 'http://www.conxn.co.in/CoxnsvcA.svc/Login');
dd($response);
I'm able to get something like this:
But while doing $response->getBody();
I'm unbale to get the response. when I do dd($response->getBody()
I'm getting:
In postman it is showing something like this:
Help me out with this.
Thanks.
This should work:
$client = new GuzzleHttp\Client();
$response = $client->request('GET','http://www.conxn.co.in/CoxnsvcA.svc/Login');
$response_body = json_decode($response->getBody());
This should work for you.
$client = new GuzzleHttp\Client();
$response = $client->request("GET", "http://www.googleapi.com", ['headers' => ['Accept' => 'application/json']]);
$response_data = json_decode((string) $response->getBody(), true);
return collect($response_data);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.