craigchilds / rls-api
Rocket League Stats PHP API
dev-master
2017-04-27 12:02 UTC
Requires
- doctrine/collections: ^1.3
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- phpspec/phpspec: ~2.0
- vlucas/phpdotenv: ^2.3
This package is auto-updated.
Last update: 2024-08-29 03:26:18 UTC
README
这是RocketLeagueStats API的非官方PHP客户端库。
安装
composer require craigchilds/rls-api
使用方法
以下是一些使用API获取不同类型数据的示例。
获取播放列表列表
use RocketLeagueStats\Stats as Api; $api = new Api([ 'api_key' => 'your_api_key_here' ]); $playlists = $api->playlists()->toCollection();
通过平台和名称获取玩家
use RocketLeagueStats\Stats as Api; use RocketLeagueStats\Data\Platform; $api = new Api([ 'api_key' => 'your_api_key_here' ]); $player = $api->player(Platform::PS4, 'PS4_UserNameHere');
在任一平台上搜索玩家
use RocketLeagueStats\Stats as Api; $api = new Api([ 'api_key' => 'your_api_key_here' ]); $results = $api->search('UserNameHere')->toCollection();
环境变量
如果您愿意,可以通过环境变量提供API密钥。假设您在项目中安装了DotEnv,您可以在您的.env
文件中添加条目。
RLS_API_KEY="rls_api_key_here"
然后您不需要在RocketLeagueStats\Stats
类的构造函数中传递它。以下是一个不带API密钥的示例批量玩家请求
use RocketLeagueStats\Stats as Api; use RocketLeagueStats\Data\Collection; $api = new Api(); $players = new Collection([ ['player' => 'UserName1', 'platform' => Platform::PS4], ['player' => 'UserName1', 'platform' => Platform::Steam], ]); $allPlayers = $api->batch($players);