tulanowski/php-riot-api

PHP 对 Riot Games API 的包装

dev-master 2015-06-18 19:46 UTC

This package is not auto-updated.

Last update: 2024-10-02 09:27:25 UTC


README

PHP 对 Riot Games API 的包装允许您使用适当的 API 密钥快速调用 RIOT API。主要特性包括缓存(如果启用)和速率限制。只需将 API_KEY_HERE 替换为从 Riot Games 获得的 API 密钥。

Testing.php 是一个简单的测试类,展示了如何调用所有函数。

入门

  • 替换 INSERT_API_KEY_HERE
  • 在脚本所在位置创建一个名为 'cache' 的文件夹(确保 php-riot-api 可以写入)
  • 创建 riotapi 的实例 - $instance = new riotapi($region);
  • $region 可以是 na, euw, eune, br, tr(br/tr 只能调用 getLeague() 和 getTeam() 函数)
  • 调用以下列出的函数并接收 JSON 数据
  • 缓存是在本地完成的,通过 "new riotapi('na', new FileSystemCache('cache/'));" 实例化 php-riot-api 来在 'cache' 子文件夹中创建缓存
  • DECODE_ENABLED 默认为 true。如果您希望返回的是纯 JSON 而不是关联数组,请将其设置为 false
  • 查看 testing.php 以获取示例代码,包括错误处理、缓存

函数

//Returns all champion information.
getChampion();

// Returns all free champions.
getFreeChampions();

//performs a static call. Not counted in rate limit.
getStatic($call, $id);

//New Riot API call. Returns match details given a match id.
getMatch($matchId);

//Returns a user's matchHistory given their summoner id.
getMatchHistory($summoner_id);

//Returns game statistics given a summoner's id.
getGame($summoner_id);

//Returns the league of a given summoner.
getLeague($summoner_id);
getLeague($summoner_id, "entry");

//Returns league information given a *list* of teams.
getLeagueByTeam($team_ids);

//Returns the challenger ladder.
getChallenger();

//Returns a summoner's stats given summoner id.
getStats($summoner_id);
getStats($summoner_id,'ranked');

//returns a summoner's id
getSummonerId($summoner_name);

//Returns summoner info given summoner id.
getSummoner($summoner_id);
getSummoner($summoner_id,'masteries');
getSummoner($summoner_id,'runes');
getSummoner($summoner_id,'name');

//Gets a summoner's info given their name, instead of id.
getSummonerByName($summoner_name);

//Gets the teams of a summoner, given summoner id.
getTeam($summoner_id);

不完整

区域检查 - 一些函数只在某些区域可用,在其他区域不可用。