proveyourskillz/lol-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

proveyourskillz/lol-api

Composer 安装命令:

composer require proveyourskillz/lol-api

包简介

Yet Another LoL API SDK Wrapper

README 文档

README

Dead simple wrapper of Riot Games API (LoL)

Requirements

  • PHP 7.1
  • works better with ext-curl installed

Installation

composer require proveyourskillz/lol-api

Creating API instance

$api = new PYS\LolApi\Api(API_KEY);

Laravel/Lumen service provider and Facade

Laravel/Lumen 5.5

ServiceProvider and Facade are registered automatically through package discovery

Laravel 5.4

In config/app.php add PYS\LolApi\Laravel\ServiceProvider as provider

Lumen 5.4

Register ServiceProvider according documentation

Optionally you can add facade to aliases 'LolApi' => PYS\LolApi\Laravel\Facade::class

After installation, you can use API through facade or inject as dependency

Usage

You can find examples of usage in examples dir

Region

You can pass region to request as 2-3 characters code but better use Region class constants

use PYS\LolApi\ApiRequest\Region;

$summoner = $api->summoner(Region::EUW, $summonerId);

Summoner

There are several ways to get Summoner: by account id, summoner id or by name

// You can get summoner in several ways by passing type in third argument
// Default version: summoner, you can ommit it
$summonerById = $api->summoner($region, $summonerId);
$summonerByAccount = $api->summoner($region, $accountId, 'account');
$summonerByName = $api->summoner($region, $name, 'name');

For more information see Summoner API reference

Match List

Recent

$matches = $api->matchList($region, $accountId);

Recent via Summoner

$matches = $api->summoner($region, $summonerId)->recentMatches();

Using query (e.g. one last match)

$matches = $api->matchList(
    $region,
    $accountId,
    [
        'beginIndex' => 0,
        'endIndex' => 1,
    ]
);

Match

Match by Id

$match = $api->match($region, $matchId);

Match within Tournament

$match = $api->match($region, $matchId, $tournamentId);

For more information see Match API reference

Leagues

Leagues and Positions of summoner by Summoner Id

$leaguesPositions = $api->leaguePosition($region, $summonerId);

Leagues and Positions of summoner via Summoner object

$leaguesPositions = $api
    ->summoner($region, $summonerId)
    ->leaguesPositions();

Leagues by Summoner Id

$leagues = $api->league($region, $summonerId);

Reusable requests and queries

Examples from above (e.g., match list request with query) are shows usage of syntax sugar methods and can be rewritten as

use PYS\LolApi\ApiRequest\MatchListRequest;
use PYS\LolApi\ApiRequest\Query\MatchListQuery;

$api = new PYS\LolApi\Api($API_KEY);

$query = new MatchListQuery;
$request = new MatchListRequest($region, $accountId);
$request->setQuery($query->lastMatches(1));

$matchList = $api->make($request);

Query objects have fluent setters for easy setup some properties like dates etc.

// Setup query object to get last 5 matches in 24 hours
$query = new MatchListQuery;
$query
    ->fromDate(new DateTime('-24 hours'))
    ->lastMatches(5);

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

Alpha version

Credits

License

MIT

统计信息

  • 总下载量: 99
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固