Fix getBotsData + Routes dans les controllers
This commit is contained in:
@@ -14,6 +14,7 @@ class DiscordApiService
|
||||
private $client;
|
||||
private $clientId;
|
||||
private $clientSecret;
|
||||
private $clientToken;
|
||||
private $redirectUri;
|
||||
private $baseUrl;
|
||||
|
||||
@@ -22,6 +23,7 @@ class DiscordApiService
|
||||
$this->client = $client;
|
||||
$this->clientId = $_ENV['DISCORD_CLIENT_ID'];
|
||||
$this->clientSecret = $_ENV['DISCORD_CLIENT_SECRET'];
|
||||
$this->clientToken = $_ENV['DISCORD_CLIENT_TOKEN'];
|
||||
$this->redirectUri = $_ENV['DISCORD_BACKEND_REDIRECT_URI'];
|
||||
$this->baseUrl = $_ENV['DISCORD_API_BASE_URL'];
|
||||
}
|
||||
@@ -62,9 +64,8 @@ class DiscordApiService
|
||||
}
|
||||
}
|
||||
|
||||
public function getBotsData(string $accessToken): array
|
||||
public function getBotsData(): array
|
||||
{
|
||||
/**
|
||||
$output = array();
|
||||
$botsId = [$_ENV['DISCORD_BOT_TAMISEUR_ID'], $_ENV['DISCORD_BOT_GROOVE_ID'], $_ENV['DISCORD_BOT_FUNKY_ID'], $_ENV['DISCORD_BOT_JUJUL_ID'], $_ENV['DISCORD_BOT_CHANTIER_ID']];
|
||||
|
||||
@@ -73,7 +74,7 @@ class DiscordApiService
|
||||
try {
|
||||
$response = $this->client->request('GET', $this->baseUrl . '/users/' . $botId, [
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . $accessToken,
|
||||
'Authorization' => 'Bot ' . $this->clientToken,
|
||||
],
|
||||
]);
|
||||
array_push($output, $response->toArray());
|
||||
@@ -81,18 +82,20 @@ class DiscordApiService
|
||||
throw new DiscordApiException($e->getCode(), 'Erreur lors de la requête à l\'API Discord: ' . $e->getMessage(), $e);
|
||||
}
|
||||
}
|
||||
return new JsonResponse($output);
|
||||
*/
|
||||
return $output;
|
||||
/*
|
||||
try {
|
||||
$response = $this->client->request('GET', $this->baseUrl . '/users/' . '262299921082875904', [
|
||||
$response = $this->client->request('GET', $this->baseUrl . '/users/' . '223831938346123275', [
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . $accessToken,
|
||||
//'Authorization' => 'Bearer ' . $accessToken,
|
||||
'Authorization' => 'Bot ' . $this->clientToken,
|
||||
],
|
||||
]);
|
||||
return $response->toArray();
|
||||
} catch (ClientExceptionInterface | ServerExceptionInterface | RedirectionExceptionInterface | TransportExceptionInterface $e) {
|
||||
throw new DiscordApiException($e->getCode(), 'Erreur lors de la requête à l\'API Discord: ' . $e->getMessage(), $e);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function getUserData(string $accessToken): array
|
||||
|
||||
Reference in New Issue
Block a user