Guzzlehttp simple request, can't find the HTML body

720 views Asked by At

my question is simple. I don't understand why I can't get the HTML body of this request on Guzzlehttp:

$client = new \GuzzleHttp\Client(['base_uri' => 'https://en.wikipedia.org/wiki/']);
$response = $client->get('PHP');
dd($response->getBody(true));

The answer is:

   Stream {#164 ▼
  -stream: :stream {@10 ▶}
  -size: null
  -seekable: true
  -readable: true
  -writable: true
  -uri: "php://temp"
  -customMetadata: []
}

What am I missing ?

1

There are 1 answers

1
Anushan Easwaramoorthy On

Cast to a string or alternatively, use the following:

$response->getBody()->__toString();