从XML获取图像 - Steam

时间:2016-02-28 00:53:24

标签: php xml

我从Steam获取XML表 - 有关此链接的Steam用户库存的信息: http://api.steampowered.com/IEconItems_730/GetPlayerItems/v0001/?key=XXXX&SteamID=XXX

实施例

{
            "id": 5267945040,
            "original_id": 4985950915,
            "defindex": 9,
            "level": 1,
            "quality": 4,
            "inventory": 3221225475,
            "quantity": 1,
            "rarity": 2,
            "flag_cannot_trade": true,
            "attributes": [
                {
                    "defindex": 6,
                    "value": 1116733440,
                    "float_value": 72
                },
                {
                    "defindex": 7,
                    "value": 1135152909,
                    "float_value": 338.11758422851563
                },
                {
                    "defindex": 8,
                    "value": 1052989602,
                    "float_value": 0.38153558969497681
                },
                {
                    "defindex": 75,
                    "value": 1457251200,
                    "float_value": 120885075771392
                },
                {
                    "defindex": 147,
                    "value": "models/weapons/stattrack.mdl"
                },
                {
                    "defindex": 39,
                    "value": 0,
                    "float_value": 0.38999998569488525
                },
                {
                    "defindex": 40,
                    "value": 0,
                    "float_value": 0.5
                },
                {
                    "defindex": 16,
                    "value": 1,
                    "float_value": 1.4012984643248171e-045
                },
                {
                    "defindex": 199,
                    "value": 30,
                    "float_value": 4.2038953929744512e-044
                },
                {
                    "defindex": 142,
                    "value": "models/weapons/w_snip_awp_icon.mdl"
                }
            ]

        }

如何下​​载阵列武器模型并在我的网站上显示它 至于这个例子

"value": "models/weapons/w_snip_awp_icon.mdl"

抱歉英语不好

1 个答案:

答案 0 :(得分:1)

我自己在获取XML数据方面经验不足。我对使用Steam API很有经验,很乐意帮助你。根据我正在阅读的内容,您尝试将游戏内视图模型models/weapons/v_snip_awp_icon.mdl与要在您的网页上显示的图片相关联。

这是一个可能有用的小模板。

XML文件:

<aaaa Version="1.0">
   <bbb>
     <cccc>
       <dddd Id="id:pass" />
       <eeee name="hearaman" age="24" />
     </cccc>
   </bbb>
</aaaa>

PHP代码段:( SimpleXMLElement是一种在PHP中获取数据而不需要升级的好方法)

$xml = new SimpleXMLElement($xmlString);
echo $xml->bbb->cccc->eeee['name'];
echo $xml->bbb->cccc->dddd['Id'];

我还建议您尝试steamanalyst.com's api