Мне нужен доступ к API, поэтому я использую guzzle6 и пишу функцию:
public function test()
{
$client = new GuzzleHttp\Client(['defaults' => ['verify' => false]]);
try {
$res = $client->post('https://example.com/api/v2/oauth/token?grant_type=client_credentials', [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
],
'auth' => [
'Username' => 'user_5639',
'Password' => 'pass_asdhbas67yausihd7qaw8'
]
]);
$res = json_decode($res->getBody()->getContents(), true);
}
catch (GuzzleHttp\Exception\ClientException $e) {
$response = $e->getResponse();
$result = json_decode($response->getBody()->getContents());
return response()->json(['data' => $result]);
}
}
но я получил ошибку:
ErrorException в строке Client.php 346: неопределенное смещение: 0
Когда я пытаюсь в POSTMAN тот же запрос, все нормально:
![enter image description here](https://i.stack.imgur.com/ODL1R.png)
Как решить мою проблему?