【发布时间】:2017-10-11 10:14:21
【问题描述】:
我正在尝试确定用户是否属于 Steam 组。为此,我使用 Steam 的 Web API,并使用 URL:
https://api.steampowered.com/ISteamUser/GetUserGroupList/v1/?key=APIKEYHERE&steamid=STEAMID64HERE
获取用户所属的所有组的 JSON 响应。 现在我想知道他们是否属于我使用 PHP 的 ID 为 1111111 的特定组。
如何做到这一点?目前我的代码是这样解码的:
$groupid = "1111111";
$url = "https://api.steampowered.com/ISteamUser/GetUserGroupList/v1/?key=APIKEYHERE&steamid=STEAMID64HERE";
$result = file_get_contents($url);
// Will dump a beauty json :)
$pretty = json_decode($result, true);
这使得 $pretty 变量包含整个 JSON 响应。 我将如何使用 PHP 在如下所示的响应中查找组 ID?
{
"response": {
"success": true,
"groups": [
{
"gid": "4458711"
},
{
"gid": "9538146"
},
{
"gid": "11683421"
},
{
"gid": "24781197"
},
{
"gid": "25160263"
},
{
"gid": "26301716"
},
{
"gid": "29202157"
},
{
"gid": "1111111"
}
]
}
}
想不通。 有什么帮助吗? :)
【问题讨论】:
-
请检查我的答案,让我有任何其他帮助
-
没用,看评论
-
检查中..请稍候
-
我已经编辑了我的答案,请再检查一次。并让我知道任何其他帮助..
-
已回复您的解决方案,但不起作用 - 引发错误。