【问题标题】:How to get body in Guzzle?如何在 Guzzle 中获得身体?
【发布时间】:2019-09-19 02:47:45
【问题描述】:

我使用这个请求:

  $client = new \GuzzleHttp\Client();
        $options = [
            'form_params' => [
                "tip" => "P",
                "voen" => "V",
                "voen" => $voen,
                "submit" => "Yoxla",
            ],
        ];
        $res = $client->request('POST', 'https://www.ebyn/payerOrVoenChecker.jsp', $options);

        dd($res->getBody());

结果我得到了这个:

Stream {#340 ▼
  -stream: stream resource @424 ▼
    wrapper_type: "PHP"
    stream_type: "TEMP"
    mode: "w+b"
    unread_bytes: 0
    seekable: true
    uri: "php://temp"
    options: []
  }
  -size: null
  -seekable: true
  -readable: true
  -writable: true
  -uri: "php://temp"
  -customMetadata: []
}

那么,如何获得真实的body,它是HTML页面?

【问题讨论】:

标签: php guzzle guzzle6


【解决方案1】:

您的解决方案:

$res->getBody()->getContents();

查看this answer了解详情。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-25
    • 2018-05-29
    • 2016-06-21
    • 2021-03-08
    • 2017-10-24
    • 1970-01-01
    • 2011-07-04
    • 1970-01-01
    相关资源
    最近更新 更多