【发布时间】:2015-08-25 12:44:32
【问题描述】:
我遇到了 GetUserStatsForGame Api 的问题。我用了
http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=<<KEY>>&steamid=<<PROFILEID>>.
我怎样才能得到球员统计数据?
我已经尝试过了,但它不起作用:/
if(!$_SESSION['steamid'] == ""){
include("settings.php");
if (empty($_SESSION['steam_uptodate']) or $_SESSION['steam_uptodate'] == false or empty($_SESSION['steam_personaname'])) {
@ $url = file_get_contents("http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=".$steamauth['apikey']."&steamids=".$_SESSION['steamid']);
$content = json_decode($url, true);
$_SESSION['total_kills'] = $content['playerstats']['stats']['total_kills'][0]['value'];
$_SESSION['steam_steamid'] = $content['response']['players'][0]['steamid'];
}
$csgoprofile['total_kills'] = $_SESSION['total_kills'];
}
请帮忙!
【问题讨论】:
-
输出的 JSON 是什么样的?快速猜测一下,
$content['playerstats'][..应该是$content['response']['playerstats'][..吗? -
{ "playerstats": { "steamID": "17343684926432", "gameName": "ValveTestApp260", "stats": [ { "name": "total_kills", "value": 41269 }, { "name": "total_deaths", "value": 41720 },