syntax / steam-api
Laravel 10+ 的 steam-api 客户端
Requires
- php: ^8.1
- ext-bcmath: *
- ext-curl: *
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
- guzzlehttp/guzzle: ^7.8
- laravel/framework: ^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.5|^11.0
- rector/rector: ^1.0
- vlucas/phpdotenv: ^5.6
- dev-master
- 3.0.0
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.2
- 2.1.0
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-laravel10
- dev-laravel9
- dev-bug-fixes
- dev-develop
- dev-laravel5
- dev-Laravel4
This package is auto-updated.
Last update: 2024-08-28 01:35:38 UTC
README
版本支持
Laravel >= 10.0
PHP >= 8.1
此包提供了一种从 Steam API 服务获取详细信息的方法。它可以访问的服务包括:
ISteamNews
IPlayerService
ISteamUser
ISteamUserStats
ISteamApp
安装
首先使用 composer 安装此包。
"require": {
"syntax/steam-api": "3.*"
}
然后,在终端中更新 composer。
composer update syntax/steam-api
或者,您可以从命令行运行 "composer require syntax/steam-api:dev-master"。
最后,发布配置文件。您可以从 Steam 获取您的 API 密钥。
php artisan vendor:publish --provider="Syntax\SteamApi\SteamApiServiceProvider"
使用
use Syntax\SteamApi\Facades\SteamApi; /** Get Portal 2 */ $apps = SteamApi::app()->appDetails(620); echo $app->first()->name;
Steam API 中的每个服务都有自己的方法可供使用。
全局
这些是每个服务可用的方法。
convertId
此功能将给定的 Steam ID 转换为每种类型的 Steam ID(64 位、32 位和 Steam ID3)。
参数
可能的格式为 ID64、id64、64、ID32、id32、32、ID3、id3 和 3。
示例用法
SteamApi::convertId($id, $format);
示例输出: convertId
新闻
用于获取游戏文章的 Steam News 网络API。
SteamApi::news()
GetNewsForApp
此方法将获取给定应用 ID 的新闻文章。它有三个参数。
参数
示例用法
<?php $news = SteamApi::news()->GetNewsForApp($appId, 5, 500)->newsitems; ?>
示例输出: GetNewsForApp
玩家
用于获取玩家详细信息的 Player Service。
实例化玩家类时,您需要传递 steamId 或 Steam 社区 ID。
SteamApi::player($steamId)
GetSteamLevel
此方法将返回 Steam 用户的等级。它只返回他们当前等级的整数。
示例输出: GetSteamLevel
GetPlayerLevelDetails
这将返回一个包含玩家等级完整详细信息的 Syntax\Containers\Player_Level 对象。
示例输出: GetPlayerLevelDetails
GetBadges
此调用将为您提供玩家当前拥有的徽章列表。目前没有徽章的架构,所以您将只得到 ID 和详细信息。
示例输出: GetBadges
GetOwnedGames
GetOwnedGames 返回玩家拥有的游戏列表以及一些游戏时间信息,如果配置文件是公开的。私有、仅好友可见和其他隐私设置不支持,除非您要求自己的个人信息(即您使用的 WebAPI 密钥链接到您请求的 steamID)。
参数
示例输出: GetOwnedGames
GetRecentlyPlayedGames
GetRecentlyPlayedGames函数返回玩家在过去两周内玩过的游戏列表,如果个人资料是公开的。不支持私人、仅好友可见和其他隐私设置,除非您请求的是您自己的个人详细信息(即您使用的WebAPI密钥与请求的steamID相关联)。
参数
IsPlayingSharedGame
如果借用的账户目前正在玩这款游戏,IsPlayingSharedGame返回原始所有者的SteamID。如果游戏未被借用或借用者当前未玩这款游戏,则结果始终为0。
参数
示例输出:IsPlayingSharedGame
用户
用于获取特定用户详情的User WebAPI调用。
在实例化用户类时,您至少需要传递一个steamId或steam社区ID。
SteamApi::user($steamId)
ResolveVanityURL
这将返回用户显示名称的详细信息。
参数
$player = SteamApi::user($steamId)->ResolveVanityURL('gabelogannewell');
示例输出:ResolveVanityURL
GetPlayerSummaries
这将返回有关一个或多个用户的详细信息。
参数
// One user $steamId = 76561197960287930; $player = SteamApi::user($steamId)->GetPlayerSummaries()[0]; // Several users $steamIds = [76561197960287930, 76561197968575517] $players = SteamApi::user($steamIds)->GetPlayerSummaries();
示例输出:GetPlayerSummaries
GetFriendList
如果Steam用户的Steam社区资料设置为“公开”,则返回任何Steam用户的好友列表。
参数
在收集好友列表后,如果summaries
未设置为false
,则通过GetPlayerSummaries传递。这允许您获取一组玩家对象。
示例输出:GetFriendList
GetPlayerBans
返回对提供的steam ID(s)可能施加的禁令。
参数
示例输出:GetPlayerBans
用户统计
用于获取用户游戏详情的User Stats WebAPI调用。
在实例化用户统计类时,您需要传递一个steamID或Steam社区ID。
SteamApi::userStats($steamId)
GetPlayerAchievements
通过app ID返回此用户的成就列表。
参数
GetGlobalAchievementPercentagesForApp
此方法将返回指定游戏的全部成就列表和每个成就被解锁的用户百分比。
参数
GetUserStatsForGame
通过app ID返回此用户的成就列表。
参数
GetSchemaForGame
返回游戏详情列表,包括成就和统计信息。
参数
示例输出:GetSchemaForGame
应用
此区域将获取游戏详情。
SteamApi::app()
appDetails
这获取了关于游戏的全部详情。这是从游戏商店页面获取的大部分信息。
参数
示例输出:appDetails
GetAppList
此方法将直接从Steam返回一个app对象的数组。它包括appID和app名称。
示例输出:GetAppList
包
此方法将获取包的详细信息。
SteamApi::package()
packageDetails
此方法获取包的所有详细信息。这是从包的商店页面获取的大部分信息。
参数
示例输出: packageDetails
物品
此方法将获取物品的用户库存。
SteamApi::item()
GetPlayerItems
此方法获取用户库存中的所有物品。
参数
⚠️ 当前已知支持: 440
, 570
, 620
, 730
, 205790
, 221540
, 238460
示例输出: GetPlayerItems
组
此服务用于获取Steam群组的详细信息。
SteamApi::group()
GetGroupSummary
此方法将获取群组的详细信息。
参数
示例用法
<?php $news = SteamApi::group()->GetGroupSummary('Valve'); ?>
示例输出: GetGroupSummary
测试Steam包
必须提供Steam API密钥,否则大多数测试将失败。
运行测试
# Build container
docker-compose build
# Install dependancies
docker-compose run --rm php composer install
# Run tests (assumes apiKey is set in .env file)
docker-compose run --rm php composer test
# Or with the apiKey inline
docker-compose run --rm -e api=YOUR_STEAM_API_KEY php composer test
# With coverage
docker-compose run --rm php composer coverage
# Play around
docker-compose run --rm php bash