lpphan/riot-api
Composer 安装命令:
composer require lpphan/riot-api
包简介
A simple wrapper for the League of Legends API.
README 文档
README
Version 0.1.1
Introduction
A simple PHP wrapper for League of legends API.
How to Install
Require the package with composer:
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.
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.
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;
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
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-21