|
|
@ -8,14 +8,20 @@ class RiotRequest { |
|
|
|
protected string $host = "https://euw1.api.riotgames.com"; |
|
|
|
protected string $host = "https://euw1.api.riotgames.com"; |
|
|
|
public array $responseHeader = array(); |
|
|
|
public array $responseHeader = array(); |
|
|
|
public int $responseCode; |
|
|
|
public int $responseCode; |
|
|
|
private bool $triedEUNE = false; |
|
|
|
private bool $isEUNE; |
|
|
|
|
|
|
|
private bool $usesRouting = false; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct($endpoint) { |
|
|
|
public function __construct($endpoint, $isEUNE=false) { |
|
|
|
$this->endpoint = $endpoint; |
|
|
|
$this->endpoint = $endpoint; |
|
|
|
|
|
|
|
$this->isEUNE = $isEUNE; |
|
|
|
|
|
|
|
if ($isEUNE){ |
|
|
|
|
|
|
|
$this->host = "https://eun1.api.riotgames.com"; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function useRouting(): void { |
|
|
|
public function useRouting(): void { |
|
|
|
$this->host = "https://europe.api.riotgames.com"; |
|
|
|
$this->host = "https://europe.api.riotgames.com"; |
|
|
|
|
|
|
|
$this->usesRouting = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setHeaders($headers): void { |
|
|
|
public function setHeaders($headers): void { |
|
|
@ -44,7 +50,7 @@ class RiotRequest { |
|
|
|
return str_replace(" ", "", $url); |
|
|
|
return str_replace(" ", "", $url); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function run() { |
|
|
|
public function run(&$successWithEUNE=false) { |
|
|
|
$opts = [ |
|
|
|
$opts = [ |
|
|
|
"http" => [ |
|
|
|
"http" => [ |
|
|
|
"method" => "GET", |
|
|
|
"method" => "GET", |
|
|
@ -58,12 +64,14 @@ class RiotRequest { |
|
|
|
preg_match_all("/HTTP\/\d\.\d\s+(\d+)\s+/", $this->responseHeader[0], $matches); |
|
|
|
preg_match_all("/HTTP\/\d\.\d\s+(\d+)\s+/", $this->responseHeader[0], $matches); |
|
|
|
$this->responseCode = intval($matches[1][0]); |
|
|
|
$this->responseCode = intval($matches[1][0]); |
|
|
|
|
|
|
|
|
|
|
|
if ($this->responseCode == 404 && !$this->triedEUNE) { |
|
|
|
if ($this->responseCode == 404 && !$this->isEUNE && !$this->usesRouting) { |
|
|
|
|
|
|
|
$this->isEUNE = true; |
|
|
|
$this->host = "https://eun1.api.riotgames.com"; |
|
|
|
$this->host = "https://eun1.api.riotgames.com"; |
|
|
|
$this->triedEUNE = true; |
|
|
|
return $this->run($successWithEUNE); |
|
|
|
return $this->run(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$successWithEUNE = $this->isEUNE; |
|
|
|
|
|
|
|
|
|
|
|
return json_decode($result); |
|
|
|
return json_decode($result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|