If expecting JSON back, the simplest way to get it:
$data = json_decode($response->getBody()); // returns an object
// OR
$data = json_decode($response->getBody(), true); // returns an array
json_decode()
will automatically cast the body to string
, so there is no need to call getContents()
.