1
votes

i am using guzzle php server client to get the result. in the array I have received the header details but did not return the expected result. is it something related to p3p? where am i doing wrong? how guzzle php client will result the body?

        $url='xyz.com';
       $client = new \GuzzleHttp\Client();
       $options = array(
        'headers' => array(
            'host' => 'xyz.com',
            'Connection' => 'keep-alive',
            'User-Agent' => 'device name is mentioned here',
            'Accept-Encoding' => 'gzip, deflate',
            'Accept-Language' => 'en-US',
        ),
        'verify' => false,
        'debug' => false,
        'allow_redirects' => array(
            'max' => 5,
            'strict' => true,
            'referer' => false,
            'protocols' => array(
                'http',
                'https'
            ),
        ),
      );

    $response = $client->request('GET', $url, $options);
    print_r($response);

   Following is the result I have received
    GuzzleHttp\Psr7\Response Object
    (
    [reasonPhrase:GuzzleHttp\Psr7\Response:private] => OK
    [statusCode:GuzzleHttp\Psr7\Response:private] => 200
    [headers:GuzzleHttp\Psr7\Response:private] => Array
    (
        [Cache-Control] => Array
            (
                [0] => no-cache
            )

        [X-XSS-Protection] => Array
            (
                [0] => 1; mode=block; report=https://www.google.com/appserve/security-bugs/log/youtube
            )

        [X-Content-Type-Options] => Array
            (
                [0] => nosniff
            )

        [Expires] => Array
            (
                [0] => Tue, 27 Apr 1971 19:44:06 EST
            )

        [P3P] => Array
            (
                [0] => CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en for more info."
            )

when I print print_r($response->getBody()); it return empty customMetadata

GuzzleHttp\Psr7\Stream Object
(
[stream:GuzzleHttp\Psr7\Stream:private] => Resource id #82
[size:GuzzleHttp\Psr7\Stream:private] => 
[seekable:GuzzleHttp\Psr7\Stream:private] => 1
[readable:GuzzleHttp\Psr7\Stream:private] => 1
[writable:GuzzleHttp\Psr7\Stream:private] => 1
[uri:GuzzleHttp\Psr7\Stream:private] => php://temp
[customMetadata:GuzzleHttp\Psr7\Stream:private] => Array
    (
    )
)
1

1 Answers

1
votes