1. Go to this page and download the library: Download league-php/leaguewrap library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
league-php / leaguewrap example snippets
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
$summoner = $api->summoner(); // Load up the summoner request object.
$bakasan = $summoner->info('bakasan'); // Get the information about this user.
$bakasan = $summoner->info(74602); // same thing as above, just to show that an id will work
echo $bakasan->summonerLevel; // 30
echo $bakasan->id; // 74602
echo $bakasan->name; // "bakasan"
echo $bakasan->profileIconId; // 24
echo $bakasan->revisionDate; // 1387391523000
echo $bakasan->revisionDateStr; // "12/18/2013 06:32 PM UTC"
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
$api->setRegion('euw'); // Set the region to 'euw'
$api->setRegion('br'); // Set the region to 'br'
$champions = $api->champion()->free(); // will throw a LeagueWrap\Api\RegionException
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
$api->remember(60); // Set the cache to remember every request for 60 seconds
// or
$api->remember(); // Enable cache with the default value for each API call.
$api->remember(null); // Same as above, null is the default value
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
$summoner = $api->summoner() // Get the summoner API request object
->remember(3600); // Remember all request done by this single request object
$bakasan = $summoner->info('bakasan'); // This request is cached for 1 hour (3600 seconds)
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
$api->remember() // Enable cache with the default values.
->setCacheOnly() // Only check the cache, don't do any http requests.
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
$api->remember(60, $myCache); // Set the cache to use your own cache implementation
// or
$api->remember(null, $myCache); // Set the cache implementation but keep the default cache times
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
$api->limit(10, 10); // Set a limit of 10 requests per 10 seconds
$api->limit(500, 600); // Set a limit of 500 requests per 600 (10 minutes) seconds
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
$api->limit(10, 10, $myLimiter); // Set a limit using your own limit implementation
$api->limit(500, 600, $myLimiter);
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the Api
$api->attachStaticData(); // Tell the api to attach all static data
$champion = $api->champion()->championById(10); // Get the champion by id 10
echo $champion->championStaticData->name; // Outputs "Kayle"
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the Api
$api->attachStaticData(); // Tell the API to attach all static data
$match = $api->match()->match(1399898747);
echo $match->team(0)->ban(0)->championStaticData->name; // outputs LeBlanc
LeagueWrap\StaticApi::mount(); // Mount all the static static proxys
Api::setKey('my-key'); // set the key for the API
$summoner = Api::summoner(); // get a LeagueWrap\Api\Summoner instance
$summoner->info('bakasan'); // get info about summoner
echo $summoner->bakasan->id; // 74602
// or
Summoner::info('bakasan'); // get info about the summoner 'bakasan'
echo Summoner::get('bakasan')->id // 74602
Game::recent(Summoner::get('bakasan')); // get the recent games for bakasan
$game = Summoner::get('bakasan')->recentGame(0); // get the most recent game
LeagueWrap\StaticApi::mount(); // Mount all the static static proxys
Api::setKey('my-key'); // set the key for the API
Api::remember(60); // cache all request for 60 seconds
$bakasan = Summoner::info('bakasan'); // cached for 60 seconds
// or
Api::remember(60, $myCache); // cache all request using my own
$bakasan = Summoner::info('bakasan'); // cached for 60 seconds using $myCache
LeagueWrap\StaticApi::mount(); // Mount all the static static proxys
Api::setKey('my-key'); // set the key for the API
Api::remember(); // cache all request for the default number of seconds
Api::limit(10, 10); // Limit of 10 request per 10 seconds
Api::limit(500, 600); // Limit of 500 request per 10 minutes
$bakasan = Summoner::info('bakasan'); // cached for 60 seconds
use LeagueWrap\Api;
$api = new Api($myKey); // Load up the API
try
{
$summoner = $api->summoner(); // Load up the summoner request object.
}
catch (LeagueWrap\Response\Http404 $e)
{
// Only thrown when a 404 http error is found
}
catch (LeagueWrap\Response\HttpClientError $e)
{
// All Http4XX extend this abstract class.
// Which is a catch all for client errors
}
catch (LeagueWrap\Response\ResponseException $e)
{
// All http error codes extends from this abstract class.
// This is a catch all (both 4xx and 5xx http errors)
// To get more detailed information about the response, the following methods are available
$e->hasResponse(); // Checks if response was attached
$response = $e->getResponse(); // Instance of LeagueWrap\Response
// In some cases like resolving 429 status codes, information from headers could be useful
// see: https://developer.riotgames.com/docs/rate-limiting
$headers = $response->getHeaders(); // ['Retry-After' => ..., ...]
$response->hasHeader('Retry-After');
$response->getHeader('that does not exist'); // null
}
catch (LeagueWrap\Response\UnderlyingServiceRateLimitReached $e)
{
// See https://github.com/paquettg/leaguewrap/issues/119
// Extends Http429 for backwards compatibility
}
$api = new \LeagueWrap\Api($myKey);
$api = new \LeagueWrap\Api($myKey, $myClient);
$game = $api->game();
$games = $game->recent(74602);
$mostRecent = $games->game(0);
// instead to access
$mostRecent = $games[0];
// traversing
foreach ($games as $game)
{
// do some stuff to each recent game
}
// counting
$recentGameCount = count($games);
$game = $api->game()
->setTimeout(3.14); // wait a maximum of 3.14 seconds for a response.
$api->setTimeout(3.14);
$game = $api->game();
$mostRecent = $game->recent(74602); // this reques will wait a maximum of 3.14 seconds for a response.
// receive a current game
$currentGame = $api->currentGame();
$game = $currentGame->currentGame($summonerId);
$game->ban(1) // first ban of the ban phase
$game->observers->encriptionKey // observer key for spectating
// participant of a game
$participant = $game->participant($summonerId)
$participant->masteries
$participant->runes
$participant->championId