嗨,我想获取 Steam 用户的人名,我已将数据存储在 .json 格式的文件中。
{
"response": {
"players": [
{
"steamid": "76561198137714668",
"communityvisibilitystate": 3,
"profilestate": 1,
"personaname": "UareBugged",
"lastlogoff": 1418911040,
"commentpermission": 1,
"profileurl": "http://steamcommunity.com/id/uarenotbest/",
"avatar": "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/avatars/da/daece8a16d866ef9bd03ddc4aa365c5862af1c21.jpg",
"avatarmedium": "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/avatars/da/daece8a16d866ef9bd03ddc4aa365c5862af1c21_medium.jpg",
"avatarfull": "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/avatars/da/daece8a16d866ef9bd03ddc4aa365c5862af1c21_full.jpg",
"personastate": 1,
"realname": "Michal Šlesár",
"primaryclanid": "103582791436765601",
"timecreated": 1400861961,
"personastateflags": 0,
"loccountrycode": "SK",
"locstatecode": "08"
}
]
}
}
而且我想将人物命名为变量,但它什么也没做,变量为空我认为 json_decode 不起作用但我真的不知道。
$pname = json_decode(file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v002/?key=KEYCONSORED&Steamids={$_SESSION['T2SteamID64']}"));
echo $pname['response']['players']['personaname'];
回声是空的