haringsrob / League-of-legends-php-class

A php class for communicating with the league of legends rest services
http://harings.be/lolclass/
3 stars 1 forks source link

'Missing' functions #1

Open kreoo opened 9 years ago

kreoo commented 9 years ago

Hello, thx again for this class! I would like to know if you have plans to add support to league2.5 api. I would like to retrieve summoner ranks and other info.

Thank you!

Edit: I ended up extending your class, it works, but Im not sure it looks as good as yours!

private function geturlleague($data, $apiv, $special = false, $ea = false)
    {
        return 'https://'.$this->region.'.api.pvp.net/api/lol/'.$this->region.'/v'.$apiv.'/'.$data.'?api_key='.$this->api_key;

    }

and

public function getsummonerleague($summoner)
    {
        // init array
        $summonerdata = array();
        // api version
        $apiv = '2.5';
        // Get the data
        $summonerdata = json_decode(
            $this->get_url_contents(
                $this->geturl('league/by-summoner/'.$summoner.'/entry', $apiv)
            )
        );

        // return data
        return $summonerdata;
    }

This will return something similar to:

{"1653955": [{
   "queue": "RANKED_SOLO_5x5",
   "name": "Teemo's Guardians",
   "entries": [{
      "leaguePoints": 0,
      "isFreshBlood": false,
      "isHotStreak": false,
      "division": "I",
      "isInactive": false,
      "isVeteran": false,
      "losses": 41,
      "playerOrTeamName": "Kreo",
      "playerOrTeamId": "1653955",
      "wins": 49
   }],
   "tier": "SILVER"
}]}

This works for me since I only wanted data from one selected summoner... but it could be extended to return data from different method in the same API.

haringsrob commented 9 years ago

Hi,

I'll look into this next week.