gpt4 book ai didi

php - Symfony 2 - Guzzle 6.X HTTP |获得 body react

转载 作者:可可西里 更新时间:2023-11-01 17:08:06 26 4
gpt4 key购买 nike

我正在使用 Guzzle使用 Symfony 2.7.3,我不知道为什么我有响应的标题而不是正文。 (我在 WAMP 的本地主机上)

$donnees = array(// Base URI is used with relative requests
'base_uri' => $urlAuth,
// You can set any number of default request options.
'timeout' => 2.0,
'headers' => [
'User-Agent' => 'testing/1.0',
'Accept' => 'application/json'
],
'verify' => false,
'json' => ["Id" => $Id,
"Username" => $username,
"Password" => $password,
"SecretId" => $secretId]
);

$client = new Client($donnees);

$response = $client->post( '/auth/', $donnees );
dump($response);

所以我得到了:

enter image description here

但是流是空的,而我应该得到一个 token (你可以看到内容长度:69)

你能帮帮我吗,我不知道我错过了......

(服务端只接受POST获取token)

最佳答案

因为它是 json 响应,你应该解码它,添加:

$response_body = json_decode($response->getBody(), true);

true 表示返回的对象将被转换为关联数组。

关于php - Symfony 2 - Guzzle 6.X HTTP |获得 body react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32311214/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com