opgg / riotquest
RiotQuest,PHP RiotAPI 客户端库,专注于从 OP.GG 的多请求
v0.9.1
2022-10-07 11:52 UTC
Requires
- php: >=5.5
- guzzlehttp/guzzle: >=6.0
- netresearch/jsonmapper: >=1.1.0
Requires (Dev)
- phpunit/phpunit: ^4.0 || ^5.0
README
功能
- DTO 支持
- 批量调用(使用 guzzlehttp promise 的异步请求)
- 您可以控制并发会话
安装
composer require opgg/riotquest
示例
use RiotQuest\Dto\LolStaticData\Champion\ChampionListDto; use RiotQuest\Dto\Summoner\SummonerDto; use RiotQuest\RequestMethod; function riotApi() { return new RiotQuest\AsyncRiotAPI('api_key'); } /** @var SummonerDto $summonerDto */ $summonerDto = $this->riotApi()->call(new RequestMethod\Summoner\SummonerByName(OPServer::getCurrentPlatform(), "kargnas")); $this->assertTrue($summonerDto instanceof SummonerDto); $this->assertTrue($summonerDto->revisionDate instanceof \RiotQuest\Dto\DateTime); $this->riotApi() ->add(new RequestMethod\Runes\RunesBySummoner(OPServer::getCurrentPlatform(), $summonerDto->id), function (\RiotQuest\Dto\Runes\RunePagesDto $runePagesDto) use ($summonerDto) { var_dump($runePagesDto->summonerId === $summonerDto->id); var_dump(array_first($runePagesDto->pages) instanceof \RiotQuest\Dto\Runes\RunePageDto); }) ->add(new RequestMethod\Masteries\MasteriesBySummoner(OPServer::getCurrentPlatform(), $summonerDto->id), function (\RiotQuest\Dto\Masteries\MasteryPagesDto $masteryPagesDto) use ($summonerDto) { var_dump($masteryPagesDto->summonerId === $summonerDto->id); var_dump(array_first($masteryPagesDto->pages) instanceof \RiotQuest\Dto\Masteries\MasteryPageDto); }) ->add(new RequestMethod\Match\MatchesByAccount(OPServer::getCurrentPlatform(), $summonerDto->accountId), function (\RiotQuest\Dto\Match\MatchlistDto $matchlist) { /** @var \RiotQuest\Dto\Match\MatchDto $match */ $match = $this->riotApi()->call(new RequestMethod\Match\MatchById(OPServer::getCurrentPlatform(), $matchlist->matches[0]->gameId)); var_dump($match instanceof \RiotQuest\Dto\Match\MatchDto); /** @var \RiotQuest\Dto\Match\Timeline\MatchTimelineDto $timeline */ $timeline = $this->riotApi()->call(new RequestMethod\Match\TimelineById(OPServer::getCurrentPlatform(), $matchlist->matches[0]->gameId)); var_dump($timeline instanceof \RiotQuest\Dto\Match\Timeline\MatchTimelineDto); var_dump($timeline->frames[0] instanceof \RiotQuest\Dto\Match\Timeline\MatchFrameDto); }) ->exec();
待办事项
- 速率限制
- PSR-6