dsjj15012 2014-04-20 18:57
浏览 70
已采纳

使用php和api显示蒸汽库存

At the moment im getting a json reponse when i query http://api.steampowered.com/IEconItems_{appid}/GetPlayerItems/v0001/?key={apikey}&steamid={steamid}&format=json

The problem however is that i dont know what to do with this reponse without any aditional info that i cant find anywhere. A part of response im getting when looking at my own cs:go inventory:

            {
            "id": 235322185,
            "original_id": 190991409,
            "defindex": 19,
            "level": 1,
            "quality": 4,
            "inventory": 70,
            "quantity": 1,
            "rarity": 4,
            "attributes": [
                {
                    "defindex": 6,
                    "value": 1130627072,
                    "float_value": 228
                },
                {
                    "defindex": 7,
                    "value": 1148436480,
                    "float_value": 975
                },
                {
                    "defindex": 8,
                    "value": 1031063904,
                    "float_value": 0.059762358665466309
                },
                {
                    "defindex": 147,
                    "value": "models\/weapons\/stattrack.mdl"
                },
                {
                    "defindex": 145,
                    "value": "models\/weapons\/w_smg_p90_mag.mdl"
                }
            ]

        },
        {
            "id": 236527226,
            "original_id": 236502674,
            "defindex": 27,
            "level": 1,
            "quality": 9,
            "inventory": 82,
            "quantity": 1,
            "rarity": 3,
            "attributes": [
                {
                    "defindex": 6,
                    "value": 1133608960,
                    "float_value": 291
                },
                {
                    "defindex": 7,
                    "value": 1142240880,
                    "float_value": 596.8505859375
                },
                {
                    "defindex": 8,
                    "value": 994750258,
                    "float_value": 0.0030927178449928761
                },
                {
                    "defindex": 80,
                    "value": 0,
                    "float_value": 0
                },
                {
                    "defindex": 81,
                    "value": 0,
                    "float_value": 0
                },
                {
                    "defindex": 147,
                    "value": "models\/weapons\/stattrack.mdl"
                },
                {
                    "defindex": 145,
                    "value": "models\/weapons\/w_shot_mag7_mag.mdl"
                }
            ]

        },
        {
            "id": 236529059,
            "original_id": 136971214,
            "defindex": 35,
            "level": 1,
            "quality": 4,
            "inventory": 77,
            "quantity": 1,
            "rarity": 2,
            "attributes": [
                {
                    "defindex": 6,
                    "value": 1077936128,
                    "float_value": 3
                },
                {
                    "defindex": 7,
                    "value": 1141712676,
                    "float_value": 564.611572265625
                },
                {
                    "defindex": 8,
                    "value": 1031160533,
                    "float_value": 0.060122329741716385
                },
                {
                    "defindex": 147,
                    "value": "models\/weapons\/stattrack.mdl"
                }
            ]

        }

The id's correnspond with the weapons and the rarity and quantity makes sense too. But i cant be expected to manually find every id of every weapon in every state right? Am i missing a different API that i can use to see what weapon corrensponds with what id?

ps: Sorry for bad english

  • 写回答

3条回答 默认 最新

  • dso407787736 2014-04-20 20:47
    关注

    You will call the GetSchema to determine which items these are. You'll compare DefIndex values against the ones returned by GetSchema

    Your work flow will look like this:

    • Call GetSchema and store result of result['items'] some place to look up later
    • Call your current call and parse through the items. For each item, look up a result in your stored value from above
    • GetSchema also has rarities and other values you may need (ie. those attributes)
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看