gpt4 book ai didi

php - Guzzle - 如何设置 json 标题?

转载 作者:行者123 更新时间:2023-12-04 15:43:55 25 4
gpt4 key购买 nike

出现Accept: application/json尚未为请求 header 设置。我没有收到 json 响应。

$params = [
'client_id' => 'xxxx',
'client_secret' => 'xxxxxxxxxx',
'code' => $request->get('code'),
'state' => $request->get('state'),
];

$client = new Client(['headers' => ['Accept: application/json']]);
$response = $client->post($tokenUrl, [
'form_params' => $params,
]);

echo $response->getBody();

我该如何解决这个问题?

最佳答案

根据 http://docs.guzzlephp.org/en/latest/request-options.html,您应该将标题编写为关联数组.

所以,试试

$client = new Client(['headers' => ['Accept' => 'application/json']]);

关于php - Guzzle - 如何设置 json 标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40451824/

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