首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >读取json steam清单

读取json steam清单
EN

Stack Overflow用户
提问于 2016-04-27 02:32:07
回答 1查看 746关注 0票数 0

我现在正在看某人的清单

代码语言:javascript
运行
复制
$inventory = file_get_contents("http://steamcommunity.com/profiles/{$Steam64}/inventory/json/730/2");

这是模拟到

代码语言:javascript
运行
复制
file_get_contents("http://api.steampowered.com/ISteamUser/GetplayerSummaries/v0002/?key={$api}&steamids={$Steam64}");

在这里我得到了steamid64

代码语言:javascript
运行
复制
{$steam->response->players[0]->personaname}

如何在清单的.json中获取特定元素?例如:

代码语言:javascript
运行
复制
{"success":true,"rgInventory":{"5904013658":{"id":"5904013658","classid":"469437901","instanceid":"302028390","amount":"1","pos":1},"5903531561":{"id":"5903531561","classid":"1293508920","instanceid":"0","amount":"1","pos":2},"5175566083":{"id":"5175566083","classid":"310780331","instanceid":"302028390","amount":"1","pos":3}

如何获得分类?我上面的解决方案不适用于此:-(

我也需要读一读:

代码语言:javascript
运行
复制
    pos":22}},"rgCurrency":[],"rgDescriptions":{"469437901_302028390":{"appid":"730","classid":"469437901","instanceid":"302028390","icon_url":"-9a81dlWLwJ2UUGcV

这一部分中的icon_url和其他内容。

问候

EN

回答 1

Stack Overflow用户

发布于 2016-04-27 02:59:22

您的响应似乎是JSON,请尝试如下所示:

代码语言:javascript
运行
复制
$inventory = file_get_contents("http://steamcommunity.com/profiles/{$Steam64}/inventory/json/730/2");
$response = json_decode($inventory, true);

这将返回您可以轻松访问的关联数组。例如$response['...']['...']

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36873049

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档