devtemple / lara-lol
这是一个可以帮助您更简单地使用《英雄联盟》API的包。
Requires
- php: >=7.1.0
- guzzlehttp/guzzle: ^6.3
This package is not auto-updated.
Last update: 2024-09-19 18:35:37 UTC
README
这是一个Laravel包,可以让您更快地从《英雄联盟》API获取数据。
入门指南
使用packagist安装此包。
安装
在终端中输入
composer require devtemple/lara-lol
设置API密钥
打开您的 .env 文件,并设置一个 LARALOL_API_KEY
,您可以在《英雄联盟》开发者API页面上生成此密钥。
选项
您可以导出配置文件
php artisan vendor:publish --tag=laralol-config
默认服务器
default_server
默认赛季
default_season
可以在每次调用端点时使用函数定义服务器
server($server)
例如。
use Devtemple\Laralol\Facades\Champion;
Champion::server('euw1')->get();
如何使用
《英雄联盟》API为我们提供了获取不同数据的端点。
每次调用端点都需要一个函数。
get($fields)
如果您想,您可以设置属性以获取调用中所需的字段。您可以定义一个包含字段或单个字段的数组。您也可以将其设置为空,以从端点获取所有数据。
例如。
get('field') or get(['field1', 'field2']) or get()
可以在 《英雄联盟》API完整参考 中找到特定端点的所有字段列表。
英雄
英雄端点让我们获取一些关于英雄的数据。这个端点没有为其指定的函数。
例如。
use Devtemple\Laralol\Facades\Champion;
Champion::get();
英雄精通
英雄精通端点让我们获取指定召唤师的英雄精通信息。我们有一些可以使用的函数来获取一些数据。
此函数让我们获取指定召唤师ID的分数。
scores($summonerId);
此函数提供每个召唤师英雄的分数信息,通过召唤师ID。
masteries($summonerId);
此函数提供特定英雄ID和召唤师ID的分数信息。
masteriesByChampion($summonerId, $championId);
例如。
use Devtemple\Laralol\Facades\ChampionMastery;
ChampionMastery::scores($summonerId)->get();
or
ChampionMastery::masteries($summonerId)->get();
or
ChampionMastery::masteriesByChampion($summonerId, $championId);
联赛
联赛端点提供关于挑战者和大师联赛以及指定召唤师的联赛的数据。您可以使用一些指定的函数来做这些。
这些组合函数可以让您获取关于挑战者或大师联赛的信息。
tier($tier); // available options: master or chall
queue($queue); // available options: solo (RANKED_SOLO_5x5) or flex (RANKED_FLEX_SR) or flextt (RANKED_FLEX_TT)
league(); // is required to get specified league - check on examples to see how to use it
此函数可以让您通过联赛ID获取联赛信息。
findById($leagueId);
此函数可以让您通过指定召唤师ID获取联赛信息。
findBySummonerId($summonerId);
例如。
use Devtemple\Laralol\Facades\League;
// You can get a challenger or master league for specified queue like this:
League::tier('chall')->queue('solo')->league()->get();
// Get league by league ID
League::findById($leagueId)->get();
// Find all leagues for specified summoner
League::findBySummonerId($summonerId)->get();
Lol状态
Lol状态端点提供关于指定服务器的信息。这个端点没有为其指定的函数。
例如。
use Devtemple\Laralol\Facades\LolStatus;
LolStatus::get();
比赛
比赛端点提供有关比赛和特定比赛的时间线的数据。这个端点有一些为其指定的函数。
您可以使用的选项是
- 英雄
- 赛季
- 队列
- beginIndex
- endIndex
- beginTime
- endTime
注意:与锦标赛代码一起使用需要针对您的API的特定策略。
findByAccountId($accountId); // Receive matches for Account ID
findByMatchId($matchId); // Receive match for Match ID
findByTournamentCode($tournamentCode); // Receive matches by Tournament code
findByMatchIdAndTournamentCode($matchId, $tournamentCode); // Receive match by Match ID and Tournament code
timeline($matchId); // Receive timeline for specific Match ID
// With under function you can filter result you would get. How you can use it you can check in examples
season($season); // Data for specific users
champion($championId); // Data for specific champion ID
queue($queue); // Data for specific queue
beginIndex($beginIndex); // Start data from specific index
endIndex($endIndex); // End data for specific index
beginTime($beginTime); // Start data for specific date (You can define normal format, timestamp or carbon instance)
endTime($endTime); // End data for specific date (You can define normal format, timestamp or carbon instance)
or
options($options); // Array with specific options champion|season|queue|beginIndex|endIndex|beginTime|endTime
例如。
use Devtemple\Laralol\Facades\Match;
// Get matches for specific account ID
Match::findByAccountId($accountId)->get();
// Get matches with specific functions options
Match::findByAccountId($accountId)
->season(10)
->beginIndex(10)
->endIndex(110)
->beginTime('12.01.2018' || $timestamp || Carbon::now()->subWeeks(12)) // Date between beginTime and endTime can't be more than one week
->endTime('15.01.2018' || $timestamp || Carbon::now()->subWeeks(12))
->get();
or
Match::findByAccountId($accountId)
->options([
'season' => 10,
'beginIndex' => 10,
'endIndex' => 110
])
->get();
观众
观众端点提供有关召唤师的信息,如果他在游戏中,或者提供特色游戏。您可以使用两个指定的函数来获取这些信息。
此函数返回您的特色游戏。
featuredGames();
此函数提供有关用户当前是否在游戏中的信息。
findById($summonerId);
例如。
use Devtemple\Laralol\Facades\Spectator;
Spectator::featuredGames()->get();
or
Spectator::findById($summonerId)->get();
召唤师
召唤师端点让我们获取有关召唤师的数据,如账户ID、召唤师ID、名称或图标ID。这个端点有一些可以让我们从《英雄联盟》API获取一些很棒数据的函数。
此函数让我们获取有关召唤师的信息。
findByName($name); // by his name
findByAccountId($id); // by his account id
findById($id); // by his ID
例如。
use Devtemple\Laralol\Facades\Summoner;
Summoner::findByName('Erring')->get();
or
Summoner::findByAccountId(29647586)->get();
or
Summoner::findById(25251096)->get();
第三方代码
第三方代码端点返回《英雄联盟》客户端中定义的第三方代码。您可以使用一个指定的函数来做这件事。
此函数为指定的召唤师提供第三方代码。
findById($summonerId);
例如。
use Devtemple\Laralol\Facades\ThirdPartyCode;
ThirdPartyCode::findById($summonerId)->get();
TOURNAMENT STUB
此端点允许您处理锦标赛代码和锦标赛比赛。这是一个用于测试的占位符,仅适用于 开发 的 LOL_API_KEY
。如果您想了解选项,请访问lol API参考并查看您可以使用的内容。
此函数提供锦标赛占位符数据
providers($options); // Creates a tournament provider and returns its ID
tournaments($options); // Creates a tournament and returns its ID.
postCodes($tournamentId, $options, $count); // Create a tournament code for the given tournament
getLobbyEvents($tournamentCode); // Gets a list of lobby events by tournament code
TOURNAMENT
此端点允许您使用锦标赛占位符端点上的所有功能以及额外的一些功能。如果您想使用此端点,您需要记住需要一个 生产
的 LOL_API_KEY
。
检查一些额外的功能
putCodes($tournamentCode); // Update the pick type, map, spectator type, or allowed summoners for a code
getCodes($tournamentCode); // Returns the tournament code DTO associated with a tournament code string
构建工具
- Guzzle - Guzzle是一个PHP HTTP客户端,它使得发送HTTP请求变得简单,并且可以轻松地与Web服务集成。
作者
- Adrian Kuriata - 初始工作 - AdrianKuriata
还可以查看参与此项目的贡献者列表。
许可证
本项目采用MIT许可证 - 有关详细信息,请参阅LICENSE.md文件。