php 作为对api的回应,象形文字出现了,

xriantvc  于 2022-11-21  发布在  PHP
关注(0)|答案(1)|浏览(107)

我正在做一个API到服务中的响应,象形文字来了,虽然在postman测试期间没有这样的东西

$client = new Client();
$client->setMethod('PUT');
$client->setUri($uri);
$client->setHeaders($headers);
$client->setRawBody(json_encode($body));
$response = $client->send();
$response = $response->getContent();

$headers = [
  'Authorization' => "************************",
  'Content-Type' => 'application/json'
];

我希望得到正确形式的json响应。

dgiusagp

dgiusagp1#

通过添加'Accept-Encoding' =〉'application/json'可以解决此问题

$client = new Client();
$client->setMethod('PUT');
$client->setUri($uri);
$client->setHeaders($headers);
$client->setRawBody(json_encode($body));
$response = $client->send();
$response = $response->getContent();

$headers = [
  'Authorization' => "************************",
  'Content-Type' => 'application/json',
  'Accept-Encoding' => 'application/json'
];

相关问题