first commit

This commit is contained in:
f4ilji
2024-09-19 16:06:49 +05:00
commit b686638a39
1664 changed files with 428174 additions and 0 deletions
@@ -0,0 +1,32 @@
<?php
$selfDir = dirname(__FILE__);
require_once $selfDir . '/../config.php';
$login = filterLogin($_POST['login']);
$password = filterPassword($_POST['password']);
$code = filterInt($_POST['code']);
$res = array();
try {
$postFields = array(
'grant_type' => 'password',
'client_id' => $clientId,
'client_secret' => $clientSecret,
'username' => $login,
'password' => $password,
'code' => $code,
'scope' => '',
);
$data = getRemoteData($apiDomainAuth . 'oauth/token', null, true, $postFields);
if ($data->success) {
setResponseCode($data->code);
$res = $data->info;
} else {
throw new Exception('Не удалось соединиться с удаленным сервером.', 522);
}
} catch (Exception $e) {
setResponseCode($e->getCode());
$res['error'] = 'Ошибка при получении токена. ' . $e->getMessage();
}
loadHeaders();
echo json_encode($res);