Retrieve the whole XML response body with Guzzle 6 HTTP Client
问题 I wanted to use Guzzle 6 to retrieve an xml response from a remote API. This is my code: $client = new Client([ 'base_uri' => '<my-data-endpoint>', ]); $response = $client->get('<URI>', [ 'query' => [ 'token' => '<my-token>', ], 'headers' => [ 'Accept' => 'application/xml' ] ]); $body = $response->getBody(); Vardumping the $body would return a GuzzleHttp\Psr7\Stream object: object(GuzzleHttp\Psr7\Stream)[453] private 'stream' => resource(6, stream) ... ... I could then call $body->read(1024)