我通过调用Steam Inventory API得到了这个回复:
{
"result":{
"status":1,
"items":[
{
"id":48331074,
"original_id":48330920,
"defindex":1013,
"level":1,
"quality":4,
"inventory":1,
"quantity":1,
"rarity":6,
"flag_cannot_trade":true,
"flag_cannot_craft":true,
"attributes":[
{
"defindex":69,
"value":1113325568,
"float_value":55
},
{
"defindex":97,
"value":0,
"float_value":0
},
{
"defindex":98,
"value":0,
"float_value":0
},
{
"defindex":99,
"value":0,
"float_value":0
},
{
"defindex":101,
"value":0,
"float_value":0
},
{
"defindex":103,
"value":0,
"float_value":0
},
{
"defindex":104,
"value":0,
"float_value":0
},
{
"defindex":106,
"value":0,
"float_value":0
},
{
"defindex":2,
"value":1,
"float_value":1.4012984643248171e-045
},
{
"defindex":71,
"value":1,
"float_value":1.4012984643248171e-045
},
{
"defindex":144,
"value":"models/inventory_items/bravo_bronze_01.mdl"
},
{
"defindex":73,
"value":600,
"float_value":8.4077907859489024e-043
}
]
},
{
"id":210417056,
"original_id":210416915,
"defindex":1024,
"level":1,
"quality":4,
"inventory":10,
"quantity":1,
"rarity":6,
"flag_cannot_trade":true,
"flag_cannot_craft":true,
"attributes":[
{
"defindex":69,
"value":1137836032,
"float_value":420
},
{
"defindex":97,
"value":4382,
"float_value":6.1404898706713484e-042
},
{
"defindex":98,
"value":273,
"float_value":3.8255448076067506e-043
},
{
"defindex":99,
"value":77,
"float_value":1.0789998175301091e-043
},
{
"defindex":101,
"value":9,
"float_value":1.2611686178923354e-044
},
{
"defindex":103,
"value":99,
"float_value":1.3872854796815689e-043
},
{
"defindex":104,
"value":661,
"float_value":9.2625828491870408e-043
},
{
"defindex":106,
"value":9,
"float_value":1.2611686178923354e-044
},
{
"defindex":2,
"value":1,
"float_value":1.4012984643248171e-045
},
{
"defindex":71,
"value":2,
"float_value":2.8025969286496341e-045
},
{
"defindex":144,
"value":"models/inventory_items/phoenix_bronze_01.mdl"
},
{
"defindex":73,
"value":600,
"float_value":8.4077907859489024e-043
}
]
},
{
"id":618061402,
"original_id":467778052,
"defindex":1030,
"level":3,
"quality":4,
"inventory":38,
"quantity":1,
"rarity":6,
"flag_cannot_trade":true,
"flag_cannot_craft":true,
"attributes":[
{
"defindex":97,
"value":2012,
"float_value":2.8194125102215319e-042
},
{
"defindex":98,
"value":94,
"float_value":1.317220556465328e-043
},
{
"defindex":99,
"value":22,
"float_value":3.0828566215145976e-044
},
{
"defindex":101,
"value":2,
"float_value":2.8025969286496341e-045
},
{
"defindex":103,
"value":54,
"float_value":7.5670117073540122e-044
},
{
"defindex":104,
"value":282,
"float_value":3.9516616693959841e-043
},
{
"defindex":171,
"value":24,
"float_value":3.363116314379561e-044
},
{
"defindex":172,
"value":137,
"float_value":1.9197788961249994e-043
},
{
"defindex":173,
"value":8,
"float_value":1.1210387714598537e-044
},
{
"defindex":174,
"value":0,
"float_value":0
},
{
"defindex":175,
"value":0,
"float_value":0
},
{
"defindex":177,
"value":17,
"float_value":2.382207389352189e-044
},
{
"defindex":179,
"value":4,
"float_value":5.6051938572992683e-045
},
{
"defindex":180,
"value":1406160000,
"float_value":1789273309184
},
{
"defindex":2,
"value":1,
"float_value":1.4012984643248171e-045
},
{
"defindex":71,
"value":3,
"float_value":4.2038953929744512e-045
},
{
"defindex":69,
"value":1065353216,
"float_value":1
},
{
"defindex":144,
"value":"models/inventory_items/breakout_gold_01.mdl"
}
]
},
{
"id":1234103906,
"original_id":901883020,
"defindex":1318,
"level":3,
"quality":4,
"inventory":19,
"quantity":1,
"rarity":6,
"flag_cannot_trade":true,
"flag_cannot_craft":true,
"attributes":[
{
"defindex":97,
"value":4399,
"float_value":6.1643119445648703e-042
},
{
"defindex":98,
"value":254,
"float_value":3.5592980993850354e-043
},
{
"defindex":99,
"value":46,
"float_value":6.4459729358941585e-044
},
{
"defindex":101,
"value":8,
"float_value":1.1210387714598537e-044
},
{
"defindex":103,
"value":114,
"float_value":1.5974802493302915e-043
},
{
"defindex":104,
"value":666,
"float_value":9.3326477724032817e-043
},
{
"defindex":171,
"value":33,
"float_value":4.6242849322718963e-044
},
{
"defindex":172,
"value":297,
"float_value":4.1618564390447067e-043
},
{
"defindex":173,
"value":12,
"float_value":1.6815581571897805e-044
},
{
"defindex":174,
"value":2,
"float_value":2.8025969286496341e-045
},
{
"defindex":175,
"value":0,
"float_value":0
},
{
"defindex":177,
"value":42,
"float_value":5.8854535501642317e-044
},
{
"defindex":179,
"value":7,
"float_value":9.8090892502737195e-045
},
{
"defindex":180,
"value":1415750400,
"float_value":3893589180416
},
{
"defindex":2,
"value":1,
"float_value":1.4012984643248171e-045
},
{
"defindex":71,
"value":4,
"float_value":5.6051938572992683e-045
},
{
"defindex":69,
"value":1065353216,
"float_value":1
},
{
"defindex":144,
"value":"models/inventory_items/vanguard_gold.mdl"
}
]
},
{
"id":2020603245,
"original_id":2020603245,
"defindex":4029,
"level":1,
"quality":4,
"inventory":65,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035927684,
"original_id":1314827449,
"defindex":4029,
"level":1,
"quality":4,
"inventory":8,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035927705,
"original_id":1294223748,
"defindex":4029,
"level":1,
"quality":4,
"inventory":51,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035927717,
"original_id":1363427501,
"defindex":4029,
"level":1,
"quality":4,
"inventory":54,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035927729,
"original_id":1363640267,
"defindex":4029,
"level":1,
"quality":4,
"inventory":53,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035927851,
"original_id":1070414833,
"defindex":4029,
"level":1,
"quality":4,
"inventory":68,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035927879,
"original_id":1161151661,
"defindex":4029,
"level":1,
"quality":4,
"inventory":66,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035927971,
"original_id":1364196175,
"defindex":4029,
"level":1,
"quality":4,
"inventory":63,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035928178,
"original_id":1351854817,
"defindex":4029,
"level":1,
"quality":4,
"inventory":55,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2035928339,
"original_id":1356562696,
"defindex":4029,
"level":1,
"quality":4,
"inventory":69,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2036053269,
"original_id":1266048733,
"defindex":4029,
"level":1,
"quality":4,
"inventory":70,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
},
{
"id":2036053294,
"original_id":1379110121,
"defindex":4029,
"level":1,
"quality":4,
"inventory":71,
"quantity":1,
"rarity":1,
"attributes":[
{
"defindex":75,
"value":1428649200,
"float_value":11507542786048
},
{
"defindex":68,
"value":29,
"float_value":4.0637655465419695e-044
}
]
}
]
}
}
我想获取项目的名称并计算它们,然后按照以下方式打印:
凤凰行动案| 21X
AWP Asiimov(经过现场测试)| 1X
操作Vanguard案例| 65X
CS:GO Case Key | 2x
我想将这些数据存储在PHP数组中。我是那种语言的初学者,你能一步一步解释我该怎么办?感谢。
答案 0 :(得分:2)
在某些游戏中检索用户广告资源的最佳方法是使用该界面
http://steamcommunity.com/profiles/[steamid]/inventory/json/[appid]/2/
例如:[appid]对于CS来说是730:GO
以下是您可以在CS中检索用户清单的示例:GO
$steamid = 'PUT YOUR STEAMID';
$destUrl = 'http://steamcommunity.com/profiles/' . $steamid . '/inventory/json/730/2/';
$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
$data = file_get_contents($destUrl, false, $context);
$data = json_decode($data, true);
作为答案,您将获得一个带有“rgInventory”和“rgDescriptions”键的json对象。
祝你好运,不要忘记在蒸汽选项中将您的库存设置为公开。