Tag: guzzle6

Guzzlehttp – 如何从Guzzle 6获得响应的身体?

我正在尝试围绕我的公司正在开发的api编写封装。 这是安静的,使用邮递员我可以发送一个post请求到像http://subdomain.dev.myapi.com/api/v1/auth/一样的用户名和密码作为POST数据,我给回了一个令牌。 所有按预期工作。 现在,当我尝试从PHP执行相同的操作时,我得到一个GuzzleHttp\Psr7\Response对象,但似乎无法像在Postman请求中那样在其内部的任何位置find该令牌。 相关的代码如下所示: $client = new Client(['base_uri' => 'http://companysub.dev.myapi.com/']); $response = $client->post('api/v1/auth/', [ 'form_params' => [ 'username' => $user, 'password' => $password ] ]); var_dump($response); //or $resonse->getBody(), etc… 上面的代码的输出看起来像(警告,传入的文本墙): object(guzzlehttp\psr7\response)#36 (6) { ["reasonphrase":"guzzlehttp\psr7\response":private]=> string(2) "ok" ["statuscode":"guzzlehttp\psr7\response":private]=> int(200) ["headers":"guzzlehttp\psr7\response":private]=> array(9) { ["connection"]=> array(1) { [0]=> string(10) "keep-alive" } ["server"]=> array(1) { [0]=> string(15) "gunicorn/19.3.0" […]