使用 koraktor 的蒸汽冷凝器,您可以轻松提取这些信息并使用它。
require_once('steam/db.php');
$_STEAMAPI = "YOURAPIKEYHERE"; // You get this from http://steamcommunity.com/dev/apikey
$playersStr = ""; // This is a comma separated list of profile IDs
// if you don't have those, Steam Condenser has functions to acquire it
$players = array(); // For this example, I'm building an array of players assuming you'll have multiple players returned.
// You are free to skip this if you are only pulling one back
$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$playersStr";
$json_object= file_get_contents($url);
$json_decoded = json_decode($json_object);
foreach ($json_decoded->response->players as $player)
{
$players[$player->steamid]['personaname'] = $player->personaname; // In game name
$players[$player->steamid]['profileurl'] = $player->profileurl; // URL to their Steam Community Page
$players[$player->steamid]['avatar'] = $player->avatar; // Small Avatar Icon URL
$players[$player->steamid]['avatarmedium'] = $player->avatarmedium; // Thumbnail avatar URL
$players[$player->steamid]['avatarfull'] = $player->avatarfull; // Full sized Avatar URL
}
如果您没有玩家的个人资料 ID,但有 Steam ID,您可以像这样获取个人资料 ID:
$profile_id = SteamId::convertSteamIdToCommunityId($steam_id);