Steam-ID:
Profil von {$name}"; if ($avatar) { echo "{$name}"; } } else { echo "

Profil nicht gefunden oder privat.

"; } // helper: baut die steam-community image-url function steam_image_url($appid, $hash) { return $hash ? "https://media.steampowered.com/steamcommunity/public/images/apps/{$appid}/{$hash}.jpg" : null; } // helper: prüft, ob URL existiert (HEAD) function url_exists($url) { $headers = @get_headers($url); return is_array($headers) && preg_match('#HTTP/\d+\.\d+\s+2\d\d#', $headers[0] ?? ''); } // fallback: holt header image aus Store API function store_header_image($appid) { $json = @file_get_contents("https://store.steampowered.com/api/appdetails?appids={$appid}&l=de"); if (!$json) return null; $data = json_decode($json, true); if (!isset($data[$appid]['success']) || !$data[$appid]['success']) return null; return $data[$appid]['data']['header_image'] ?? null; } // rendert ein Game-Item (Name + Bild + Zeit) function render_game_li($appid, $name, $hash, $altHours = '') { $img = steam_image_url($appid, $hash); if (!$img || !url_exists($img)) { // versuch icon hash (falls hash war logo). $hash kann beides sein, aber wir prüfen nochmal nichts gefunden -> store header $storeHeader = store_header_image($appid); $img = $storeHeader ?: 'https://via.placeholder.com/150?text=No+Image'; } $hours = $altHours !== '' ? " - $altHours h" : ''; echo "
  • \""
    " . htmlspecialchars($name) . "{$hours}
  • "; } // --- Zuletzt gespielt --- $recentUrl = "https://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v1/?key={$steamApiKey}&steamid={$steamId}&count=7"; $recentJson = @file_get_contents($recentUrl); $recentData = $recentJson ? json_decode($recentJson, true) : null; echo "

    Zuletzt gespielt

    "; // --- Meistgespielt --- $ownedUrl = "https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?key={$steamApiKey}&steamid={$steamId}&include_appinfo=1&include_played_free_games=1"; $ownedJson = @file_get_contents($ownedUrl); $ownedData = $ownedJson ? json_decode($ownedJson, true) : null; $games = $ownedData['response']['games'] ?? []; usort($games, fn($a,$b) => ($b['playtime_forever'] ?? 0) <=> ($a['playtime_forever'] ?? 0)); echo "

    Meistgespielt

    "; $ownedUrl = "https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?key={$steamApiKey}&steamid={$steamId}&include_played_free_games=1"; $ownedData = json_decode(file_get_contents($ownedUrl), true); $totalMinutes = 0; if (!empty($ownedData['response']['games'])) { foreach ($ownedData['response']['games'] as $game) { $totalMinutes += $game['playtime_forever'] ?? 0; // Minuten } } $totalHours = round($totalMinutes / 60, 1); $totalHoursOutput = "Insgesamt gespielt: {$totalHours} Stunden"; echo "

    $totalHoursOutput

    "; } else { echo "

    Gebe die Steam-ID an

    "; } ?>