Closed Lucasnl closed 5 years ago
Hey, that is a pretty good question!
Without any library code change it is possible but in a restricted way - if you override DataDragonAPI::SET_ENDPOINT
during library initialization to local URL:
DataDragonAPI::initByVersion('custom_version_string', [
DataDragonAPI::SET_ENDPOINT => 'http://localhost/riot-api-files/',
]);
All the generated URLs will then contain this one as a base path instead of https://ddragon.leagueoflegends.com/cdn/
, but you will still need to follow original directory structure by which it is accessible through official CDN URL.
Eg. for champion icons its:
"{$endpoint}{$version}/img/champion/{$champion_name}.png";
thanks for the reply ! I will try to implement this .
Just did it ! thanks again! , but one more question. Even using the data dragon local files , I still have a long TTFB (time to first byte) around 12 seconds, in other words is taking 12 seconds to load the entire page , is this normal or am I missing something ?
@Lucasnl, it pretty much depends on your setup - what server do you use, what does the page do - I can't judge without any additional information.
@dolejska-daniel Im using localhost / Xampp
@dolejska-daniel Im using localhost / Xampp
That doesn't tell me anything about your code 😅. 12 seconds is very long, so either you are doing something wrong or you've got something configured wrong.
well Here's an example , i have a input to search players match history so ... $player =$_POST['searchPlayer']
if ($player ) { $getSummoner=$api->getSummonerByName($player); $sumId = $getSummoner->accountId; $getGames= $api->getMatchlistByAccount($sumId); $games = $getGames->matches; } // This is what i'm doing to get all the info I need for the match history
now im doing a foreach to get all the detailed infos about the game
foreach ($games as $game) {
$ranked = $game->queue;
$gameId= $game->gameId;
$infoGame = $api->getMatch($gameId);
$getAllPlayers=$infoGame ->participantIdentities;
$stats = $infoGame ->participants;
// and now I have another foreach inside this foreach to access all the info about the player id
foreach ($getAllPlayers as $player) {
$participantMatchId= $player->participantId;
// and another foreach inside this foreach to get the stats and items about the game
foreach ($stats as $stat){
$WinorLose= $stat->stats->win;
$item0 = $stat->stats->item0 $item1 = $stat->stats->item1 .... } }
}
and that's it , I don't know if a foreach inside another foreach is a problem or there's another way to do it , im kinda new on this.
Ok, I can see why this could take a lot of time since you are querrying the API separately for each game from matchlist. You could probably use async requests to speed up the process but you'd have to change your code a bit.
Thanks for the reply! I will try !
Hey its me again ,I promise this is the last time I bother you 😅
I tried to follow your the example from the Async request , I'm doing the league api initializating with my riot key , but all im getting is a blank page , im not getting the output :
I am TheKronnY (level 69)
I m Professor (level 106)
TehExuilKujdž (level 154)
is there any other config I have to make ?
@Lucasnl these summoner names are from EUNE region - that is important.
Btw code utilizing asynchronous requests would look something like this for case you presented:
$player = $_POST['searchPlayer'];
if ($player)
{
$getSummoner = $api->getSummonerByName($player);
$sumId = $getSummoner->accountId;
$getGames = $api->getMatchlistByAccount($sumId);
$games = $getGames->matches;
}
$onSuccess = function( Objects\MatchDto $infoGame ) {
$getAllPlayers = $infoGame->participantIdentities;
$stats = $infoGame->participants;
foreach ($getAllPlayers as $player)
{
$participantMatchId = $player->participantId;
foreach ($stats as $stat)
{
$WinorLose = $stat->stats->win;
$item0 = $stat->stats->item0;
$item1 = $stat->stats->item1;
// ...
}
}
};
$onFailure = function( $ex ) {
echo "Error occured: {$ex->getMessage()}";
};
foreach ($games as $game)
{
$ranked = $game->queue;
$gameId = $game->gameId;
$api->nextAsync($onSuccess, $onFailure);
$infoGame = $api->getMatch($gameId);
}
$api->commitAsync();
thanks for the help !
@Lucasnl there has been a mistake in my code - last line is supposed to be $api->commitAsync();
not $api->commitAsync("accounts");
. Make sure you fix it too 😅
I'm assuming this has been solved.
I just downloaded the data dragon files , and i want to know if it's possible (and easy to implement) to use the local files instead of using the cdn.
Thank you