From edabf6060d782b0651b698a322288c4f3335505f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9C=D0=B8?= =?UTF-8?q?=D1=85=D0=BD=D0=BE?= Date: Wed, 14 Aug 2024 02:32:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auth.php | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 auth.php create mode 100644 index.php diff --git a/auth.php b/auth.php new file mode 100644 index 0000000..4722178 --- /dev/null +++ b/auth.php @@ -0,0 +1,57 @@ + $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; +} +?> + diff --git a/index.php b/index.php new file mode 100644 index 0000000..11fb100 --- /dev/null +++ b/index.php @@ -0,0 +1,60 @@ +Баланс вашего кошелька: ' . $balance . ' руб.'; + +// Получаем историю операций (последние 5 операций) +$params = array( + 'records' => 5, +); +$operationHistory = apiRequest($operationHistoryUrl, $token, $params); + +// Выводим последние 5 операций +echo 'Последние 5 операций:
'; +foreach ($operationHistory['operations'] as $operation) { + echo 'Дата: ' . $operation['datetime'] . '
'; + echo 'Сумма: ' . $operation['amount'] . ' руб.
'; + echo 'Тип: ' . $operation['title'] . '
'; + echo 'Описание: ' . $operation['message'] . '
'; + echo '
'; +} +?>