gpt4 book ai didi

PHP json_decode 不起作用

转载 作者:可可西里 更新时间:2023-11-01 13:41:17 25 4
gpt4 key购买 nike

您好,我想获取 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'];

echo 是空的

最佳答案

玩家是一个数组:

$pname['response']['players'][0]['personaname'];

关于PHP json_decode 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27551122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com