Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetMatches and rate limiting #71

Open
SeaRoth opened this issue Dec 9, 2017 · 6 comments
Open

GetMatches and rate limiting #71

SeaRoth opened this issue Dec 9, 2017 · 6 comments

Comments

@SeaRoth
Copy link

SeaRoth commented Dec 9, 2017

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

@dakotawashok
Copy link

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

@SeaRoth
Copy link
Author

SeaRoth commented Dec 12, 2017

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

@dakotawashok
Copy link

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

@SeaRoth
Copy link
Author

SeaRoth commented Dec 13, 2017

Thanks boss! xD

@dakotawashok
Copy link

dakotawashok commented Dec 13, 2017

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
Copy link

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants