CP =“这不是P3P政策!有关详细信息,请参阅http://support.google.com/accounts/answer/151657?hl=en。”

时间:2018-03-19 07:16:27

标签: curl guzzle guzzlehttp p3p

我正在使用guzzle php服务器客户端来获取结果。 在数组中我收到了标题详细信息,但没有返回预期的结果。它与p3p有关吗?我在哪里做错了?怎么guzzle php客户端会导致身体?

        $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."
            )

当我打印print_r($ response-> getBody());它返回空的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 个答案:

答案 0 :(得分:1)

$response->getBody()->getContents()

有关详细信息,请参阅Guzzlehttp - How get the body of a response from Guzzle 6?