php-riot-api icon indicating copy to clipboard operation
php-riot-api copied to clipboard

GetMatches and rate limiting

Open SeaRoth opened this issue 7 years ago • 6 comments

Is there a timeline for completion of the $api->getMatches($ids, $timeline=true) ?

SeaRoth avatar Dec 09 '17 16:12 SeaRoth

@SeaRoth It should already be done, I'm getting the timeline in my match calls, are you not?

dakotawashok avatar Dec 12 '17 18:12 dakotawashok

Yeah, maybe I'm doing something wrong, both getMatches and getMatch are returning null.

Output:

image

Code:

$api = new riotapi('NA1', new FileSystemCache('cache/'));
$name = "The SeaRoth";
$id = 32493361;
$theMatchList;

try {
    $theMatchList = $api->getMatchList($id,$params=null);
} catch(Exception $e) {
    echo "Error: " . $e->getMessage();
};

$match1 = $theMatchList['matches'][0]['gameId'];
$match2 = $theMatchList['matches'][1]['gameId'];
echo "Match #1: " . $match1 . "<br>";
echo "Match #2: " . $match2 . "<br>";
echo "<br><br>";
echo "matches";
echo "<br><br>";

try{
    $rMatches = $api->getMatches([$match1,$match2], $includeTimeline = true);
    print_r(json_encode($rMatches));
}catch(Exception $e){
    echo "Error: " . $e->getMessage();
}

echo "<br><br>";
echo "match";
echo "<br><br>";
try{
    $rMatch = $api->getMatch($match1,false);
    print_r(json_encode($rMatch));
}catch(Exception $e){
    echo "Error: " . $e->getMessage();
}

Api Key Usage:

image

SeaRoth avatar Dec 12 '17 19:12 SeaRoth

I'll take a look at it later tonight after work, but that looks like it should be working

dakotawashok avatar Dec 12 '17 20:12 dakotawashok

Thanks boss! xD

SeaRoth avatar Dec 13 '17 02:12 SeaRoth

Looks like my laptop isn't working at home lmao, I can take a look at it more when I get to work tomorrow, sorry bud! I also haven't used getMatches before with an array, usually I just use the array and loop through it doing getMatch calls. If you want to take a look at a big example of how I'm using the api check out : https://github.com/dakotawashok/loldashboard/blob/master/app/Http/Controllers/SummonerController.php

dakotawashok avatar Dec 13 '17 02:12 dakotawashok

@SeaRoth Looks like you're right! getMatches isn't working, and it looks like it's because of a currently undefined method on line 183 of php-riot-api.php called requestMultiple(). I've altered your code to work around this:

`$name = "The SeaRoth"; $id = 32493361; $theMatchList;

    try {
        $theMatchList = $this->api->getMatchList($id,$params=null);
    } catch(Exception $e) {
        $this->log("Error: " . $e->getMessage());
    };

    $match1 = $theMatchList->matches[0]->gameId;
    $match2 = $theMatchList->matches[1]->gameId;
    $this->log("Match #1: " . $match1);
    $this->log("Match #2: " . $match2);
    $this->log("matches");

    try{
        $definedMatches = [];
        foreach([$match1, $match2] as $gameId) {
            $rMatch = $this->api->getMatch($gameId,false);
            $this->log($rMatch);
            array_push($definedMatches, $rMatch);
        }
    }catch(Exception $e){
        $this->log("Error: " . $e->getMessage());
    }`

and the output works. Note that I've replaced your echos with my log function, but they both do the same thing :)

dakotawashok avatar Dec 13 '17 16:12 dakotawashok