Questions tagged «guzzle6»

2
Guzzlehttp-如何从Guzzle 6获得响应的主体?
我正在尝试为我公司正在开发的API编写包装器。这很安静,使用邮递员,我可以向http://subdomain.dev.myapi.com/api/v1/auth/用户端发送一个邮寄请求,例如使用用户名和密码作为POST数据,并且还给我一个令牌。所有工作均按预期进行。现在,当我尝试从PHP执行相同操作时,我得到了一个GuzzleHttp\Psr7\Response对象,但似乎无法像在Postman请求中那样在其内部的任何地方找到令牌。 相关代码如下: $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]=> …
163 php  response  guzzle  guzzle6 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.