$code, 'client_id' => $client_id, 'redirect_uri' => $redirect_uri, 'grant_type' => 'authorization_code' ); // Выполнение POST запроса для получения токена $options = array( 'http' => array( 'header' => "Content-Type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), ), ); $context = stream_context_create($options); $result = file_get_contents($token_url, false, $context); if ($result === FALSE) { die('Ошибка при получении токена'); } $response = json_decode($result, true); if (isset($response['error'])) { die('Ошибка: ' . $response['error_description']); } $access_token = $response['access_token']; echo "Ваш access token: " . $access_token; } ?>