2017 © Pedro Peláez
 

library riot-api

A simple wrapper for the League of Legends API.

image

lpphan/riot-api

A simple wrapper for the League of Legends API.

  • Friday, August 5, 2016
  • by lamphuong223
  • Repository
  • 1 Watchers
  • 1 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 8 % Grown

The README.md

League of Legends API wrapper in PHP

Version 0.1.1, (*1)

Introduction

A simple PHP wrapper for League of legends API., (*2)

How to Install

Require the package with composer:, (*3)

composer require lpphan/riot-api

Example usage

use Lpphan\RiotApi;

// Load up the API
$api = new RiotApi($apiKey);  

// Load up the summoner api object.                         
$summoner = $api->summonerApi();    

// Get the information about this user, this will return an Lpphan\Response object                  
$response  = $summoner->getSummonerByNames($arrayOfSummonerName);    

$info = $response->getBody();
print_r($info);

Regions

You can set the region that you wish to query. By default it is 'na' but it can be changed., (*4)

use Lpphan\RiotApi;
use Lpphan\Regions;

// Load up the API
$api = new RiotApi($apiKey);
$api->setRegion(Regions::BR);

//or
$summoner = $api->summonerApi();
$api->setRegion(Regions::BR);
$summoner->getSummonerByNames($array);

Cache

By default, the cache requires memcached to be installed and operating on default port and localhost., (*5)

use Lpphan\RiotApi;

$api = new RiotApi($apiKey);                        
$summoner = $api->summonerApi();    

//Cache this response for 5 minutes
$response = $summoner->getSummonerByNames(['summonerName'])->remember(5);

//or use this
$api->remember($response,5);

The cache can be changed by implement your own version of Lpphan\CacheInterface;, (*6)

use Lpphan\RiotApi;

//set custom cache
$api = new RiotApi($apiKey,$cacheProvider);

//or use this
$api->setCache($cacheProvider);                         

Exceptions handling

use Lpphan\RiotApi;

$api = new RiotApi($apiKey);
$summoner = $api->summonerApi();

try{
    $response = $summoner->getSummonerByNames(['summonerName']);
}catch (Lpphan\Exception\Http404Exception $e){
    //throw when a 404 http error is found
}catch (Lpphan\Exception\Http429Exception $e){
        //Rate limit exceeded
        //Should retry after
        $seconds = $e->retryAfter();
}catch (Lpphan\Exception\HttpException $e){
    //throw for all http error
}               

//Todo : add doc, (*7)

The Versions

05/08 2016

dev-master

9999999-dev

A simple wrapper for the League of Legends API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lam Phuong Phan

api proxy facade wrap lol league of legends riot

05/08 2016

0.1.1

0.1.1.0

A simple wrapper for the League of Legends API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lam Phuong Phan

api proxy facade wrap lol league of legends riot

22/06 2016

0.1.0

0.1.0.0

A simple wrapper for the League of Legends API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lam Phuong Phan

api proxy facade wrap lol league of legends riot