Skip to content

Commit

Permalink
Update tournament API
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Pardons committed Feb 28, 2020
1 parent 777b887 commit 314f0dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/backend/modules/matchs/actions/actions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ private function fetchTournaments(ToornamentAPI $api)
$filename = $folder . DIRECTORY_SEPARATOR . "toornament-tournaments.json";
if (!file_exists($filename) || @filemtime($filename) + 60 * 2 < time()) {
try {
$tournaments = $api->get("v1/me/tournaments", array(), true);
$tournaments = $api->get("organizer/v2/tournaments", ['disciplines' => 'counterstrike_go'], true, ["Range: tournaments=0-49"]);
} catch (Exception $e) {
}

Expand Down
9 changes: 5 additions & 4 deletions lib/ToornamentAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ private function prepare($uri, $needOAuth = false, $headers = array())
}


public function get($uri, $params = array(), $needOAuth = false)
public function get($uri, $params = array(), $needOAuth = false, $headers = [])
{
if (count($params) > 0) {
$uri .= "?" . http_build_query($params);
}

$ch = $this->prepare($uri, $needOAuth);
$ch = $this->prepare($uri, $needOAuth, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpcode == 200) {
if ($httpcode < 300) {
return json_decode($result, true);
} else {
throw new Exception("{$this->baseUrl}$uri returned $httpcode");
Expand Down Expand Up @@ -146,7 +146,8 @@ private function requestOAuth2()
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
"grant_type" => 'client_credentials',
"client_id" => $this->clientId,
"client_secret" => $this->clientSecret
"client_secret" => $this->clientSecret,
"scope" => 'organizer:admin organizer:view organizer:result'
)));

$result = curl_exec($ch);
Expand Down

0 comments on commit 314f0dd

Please sign in to comment.