使用steam API来获取用户的库存物品

我一直在网站上工作,此刻我试图拉动蒸汽用户的物品并显示在 网页。 我对这种东西很陌生
这是我到目前为止的代码:</ p>

http://pastebin.com/gHAv4Azb </ p>

以下是JSon的链接:
http://steamcommunity.com/profiles/76561198073134556/inventory/json/730/2 </ p>

< p>任何帮助都将非常感谢!! </ p>
</ div>

展开原文

原文

I've been working on a site and at the moment i any trying pull the steam users items and display on a web page. I'm pretty new to this kind of stuff this is the code i have so far:

http://pastebin.com/gHAv4Azb

and here is the link to the JSon: http://steamcommunity.com/profiles/76561198073134556/inventory/json/730/2

Any help at all will be hugely appreciated!!

dongningwen1146
dongningwen1146 你能具体告诉我们你遇到的问题吗?从您上面链接的代码判断,您试图显示每个项目的名称。名称没有正确显示?
4 年多之前 回复

1个回答

You can change this statement foreach($myarrayGetInv['result'][$item['classid']] as $item_A) to foreach($myarrayGetInv['result'] as $classid => $item_A) and add a conditional inside this loop if($classid == $item['classid']) echo $item_A['name'];

The structure you request looks like this:

"result": {
    "item (classid)": {
        "attribute_name": "attribute_value"
        ...
    }
}

The former statement will loop through each name/value pair. While, the latter will loop through each item and enables you to access the name like you intended $item['name'].

Its hard to debug when you suppress errors by prepending the variable with @.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐