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条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改