callisto/riot-api-wrapper

此包的最新版本(2.0.2)没有可用的许可信息。

RiotApiWrapper (RAW)

2.0.2 2023-06-08 09:21 UTC

This package is auto-updated.

Last update: 2024-09-08 12:16:51 UTC


README

RAW(RiotApiWrapper)是一个PHP项目,旨在为Riot Games API提供包装器,允许开发者轻松访问API提供的数据和服务。通过此包装器,用户可以通过简单直观的PHP代码访问API,无需担心API的底层技术细节。

我们的目标是让尽可能多的人能够访问Riot Games API,无论他们的技术背景或专业水平如何。通过简化接口和提供清晰的文档,RAW使更多开发人员能够利用Riot Games API提供的大量数据和服务的优势。

使用Composer管理依赖项,RAW设计得易于安装并集成到任何PHP项目中。无论是从头开始构建新应用程序还是向现有项目添加新功能,RAW都将使您轻松地将Riot Games API集成到代码中。

因此,如果您正在寻找一种简单可靠的方式与Riot Games API合作,RAW就是您的不二选择。凭借清晰的文档、直观的代码和Composer的支持,RAW是任何希望充分利用Riot Games API的人的完美选择。

为下一个更新优先级(3.0.0)投票: https://strawpoll.com/polls/X3nk4qODEgE

投票历史

部署

要安装此项目,请运行

composer require callisto/riot-api-wrapper

RAW需要Symfony 6.2或更高版本以及php 8.0或更高版本

用法

$raw = new \Callisto\RiotApiWrapper\RiotApiWrapper('YOUR_API_KEY');

要获取您的API密钥,请在Riot开发者门户中创建账户。然后,转到仪表板并点击生成开发密钥的按钮。要获取永久密钥,请在Riot Games开发者网站上注册您的应用程序并等待批准。一旦批准,您就可以使用永久API密钥访问Riot的API。

https://developer.riotgames.com/

$summoner = $raw->LOL('EUW1')->Summoner()->byName('NAME');

参考资料

您可以在以下位置查看原始Riot API文档: https://developer.riotgames.com/apis

平台和地区列表

平台列表

['BR1','EUN1','EUW1','JP1','KR','LA1','LA2','NA1','OC1','TR1','RU','PH2','SG2','TH2','TW2','VN2']

地区列表

['AMERICAS','ASIA','EUROPE','SEA']

包装器参考资料

Riot

// Riot/Account

- Riot()->Account(string $region)->byPuuid(string $puuid)
- Riot()->Account(string $region)->byGame(string $game, string $puuid)

LOL

// LOL/ChampionMastery

- LOL()->ChampionMastery(string $platform)->bySummoner(string $encryptedSummonerId)
- LOL()->ChampionMastery(string $platform)->byChampion(string $encryptedSummonerId, string $championId)
- LOL()->ChampionMastery(string $platform)->top(string $encryptedSummonerId)
- LOL()->ChampionMastery(string $platform)->scores(string $encryptedSummonerId)
// LOL/ChampionMastery

- LOL()->Champion(string $platform)->rotations()
// LOL/Clash

- LOL()->Clash(string $platform)->byPuuid(string $puuid)
- LOL()->Clash(string $platform)->bySummoner(string $summonerId)
- LOL()->Clash(string $platform)->team(string $teamId)
- LOL()->Clash(string $platform)->tournaments()
- LOL()->Clash(string $platform)->tournamentsByTeam(string $teamId)
- LOL()->Clash(string $platform)->tournamentsById(string $tournamentId)
// LOL/LeagueExp

- LOL()->LeagueExp(string $platform)->exp(string $queue, string $tier, string $division)
// LOL/League

- LOL()->League(string $platform)->byQueue(string $queue)
- LOL()->League(string $platform)->bySummonerId(string $summonerId)
- LOL()->League(string $platform)->byQueueTierDivision(string $queue, string $tier, string $division)
- LOL()->League(string $platform)->grandMasterLeagues(string $queue)
- LOL()->League(string $platform)->leagueId(string $leagueId)
- LOL()->League(string $platform)->masterLeagues(string $queue)
// LOL/Challenges

- LOL()->Challenges(string $platform)->challenges()
- LOL()->Challenges(string $platform)->percentiles()
- LOL()->Challenges(string $platform)->challengeIdConfig(string $challengeId)
- LOL()->Challenges(string $platform)->leaderboardByLevel(string $challengeId, string $level)
- LOL()->Challenges(string $platform)->percentilesByChallengeId(string $challengeId)
- LOL()->Challenges(string $platform)->playerData(string $puuid)
// LOL/Status

- LOL()->Status(string $platform)->status()
// LOL/Matches

- LOL()->Status(string $region)->ids(string $puuid, array $options = [])
- LOL()->Status(string $region)->match(string $matchId)
- LOL()->Status(string $region)->timeline(string $matchId)
// LOL/Spectator

- LOL()->Spectator(string $platform)->activeGames(string $summonerId)
- LOL()->Spectator(string $platform)->featuredGames()
// LOL/Summoner

- LOL()->Summoner(string $platform)->byAccount(string $accountId)
- LOL()->Summoner(string $platform)->byName(string $summonerName)
- LOL()->Summoner(string $platform)->byPuuid(string $puuid)
- LOL()->Summoner(string $platform)->bySummonerId(string $summonerId)

TFT(⭐ 新增)

// TFT/League

- TFT()->League(string $platform)->challenger()
- TFT()->League(string $platform)->bySummonerId(string $summonerId)
- TFT()->League(string $platform)->byTierAndDivision(string $tier, string $division, array $options = [])
- TFT()->League(string $platform)->grandmaster()
- TFT()->League(string $platform)->byLeagueId(string $leagueId)
- TFT()->League(string $platform)->master()
- TFT()->League(string $platform)->topByQueue(string $queue)
// TFT/Matches

- TFT()->Matches(string $region)->ids(string $puuid, array $options = [])
- TFT()->Matches(string $region)->match(string $matchId)
// TFT/Status

- TFT()->Status(string $platform)->platformData()
// TFT/Summoner

- TFT()->Summoner(string $platform)->byAccountId(string $accountId)
- TFT()->Summoner(string $platform)->byName(string $name)
- TFT()->Summoner(string $platform)->byPuuid(string $puuid)
- TFT()->Summoner(string $platform)->bySummonerId(string $summonerId)

LORT

🚧 进行中

Valorant

🚧 进行中

示例

LOL

// Get recent LoL matches exemple

require __DIR__ . '/../../vendor/autoload.php';

$raw = new \Callisto\RiotApiWrapper\RiotApiWrapper('YOUR_API_KEY'); // Init RiotApiWrapper
$raw->Cache(); // (Optional) Enable cache.


// (Optional) Request options
$options = [
    'startTime' => strtotime('01/01/2023'), // (Optional) timestamp (seconds). Before this date, matches won't be included in result.
    'endTime'   => strtotime('now'), // (Optional) timestamp (seconds). After this date, matches won't be included in result.
    'queue'     => 400, // (Optional) queue id.
    'type'      => 'normal', // (Optional) match type
    'start'     => 0, // (Optional) Start index
    'count'     => 20, // (Optional) max results count
];

try {

    $matchesIds = $raw->LOL()->Matches('EUROPE')->ids('PUUID',$options); // Return matches ids list

    foreach ($matchesIds as $matchId){
        $matches[] = $raw->LOL()->Matches('EUROPE')->match($matchId); // Return match datas from match id
    }

    print_r($matches);

}Catch(Exception $exception){
    exit($exception->getMessage());
}Catch(\Callisto\RiotApiWrapper\Exceptions\RequestExceptions $exception){
    exit($exception->getMessage());
}
// Search summoner

$name = 'example'; // Summoner name to search

$raw = new \Callisto\RiotApiWrapper\RiotApiWrapper('YOUR_API_KEY'); // Init RiotApiWrapper
$raw->Cache(); // (Optional) Enable cache.

$searchPlatform =  ['BR1','EUN1','EUW1','JP1','KR','LA1','LA2']; // Select platforms you want to search on

try {

    foreach ($searchPlatform as $platform){
        $results[$platform] = $raw->LOL()->Summoner($platform)->byName($name); // Save result even if empty
    }
    
}catch (\Callisto\RiotApiWrapper\Exceptions\RequestExceptions $exception){
    exit($exception->getMessage());
} catch (Exception $e) {
    exit($e->getMessage());
}


print_r($results);

TFT

// Get summoner and last match

require __DIR__ . '/../../vendor/autoload.php';

$raw = new \Callisto\RiotApiWrapper\RiotApiWrapper('YOUR_API_KEY'); //Init RiotApiWrapper
$raw->Cache(); // (Optional) Enable cache.

try {

    $summoner = $raw->TFT()->Summoner('EUW1')->byName('NAME'); // Get {NAME} summoner data

    $options = [
        'count' => 1, // (Optional) max results count
    ];

    $lastMatchId = $raw->TFT()->Matches('EUROPE')->ids($summoner['puuid'],$options)[0]; // Get last match id

    $lastMatch = $raw->TFT()->Matches('EUROPE')->match($lastMatchId); // Get $lastMatchId match data

    print_r($lastMatch);

} catch (Exception $exception) {
    exit($exception->getMessage());
} catch (\Callisto\RiotApiWrapper\Exceptions\RequestExceptions $exception) {
    exit($exception->getMessage());
}

返回示例

$summoner = $raw->LOL()->Summoner('BR1')->byName('frosty');
array(7) {
    ["id"]              => string(47) "d28PpG7Udqz1DC426V0xhBcExDZ21m8eYY9Ys9zhOOsKjNM"
    ["accountId"]       => string(47) "f_WSG9mgV23Zxh132C_9d2o1DMYg3Rq9sPp_APHp1QGlcdA"
    ["puuid"]           => string(78) "oB7jr-sPTP2Vs8Y6fglY345VFRdjNfxfPoAsXI3ViJbBlAmWCvN81igfZO88Y5_5JlCQreBKKO4uA"
    ["name"]            => string(6) "frosty"
    ["profileIconId"]   => int(5490)
    ["revisionDate"]    => int(1681258365846)
    ["summonerLevel"]   => int(813)
}

贡献

欢迎贡献!如果您发现错误或有功能请求,请打开一个问题。

许可

RAW是开源软件,根据MIT许可证发布。