循环浏览玩家清单 Steam PHP
Looping Through players inventory Steam PHP
你好,我只是想知道是否有办法检查
中的所有项目
用户盘点并回显物品名称和物品图片,
我应该使用 rgInventory 还是 rgDescriptions?
我应该如何遍历它?
抱歉我很笨
您需要获取玩家 steam id
库存:
http://steamcommunity.com/profiles/steam_id/inventory/json/730/2
将 steam_id 替换为您的 steam id
和 730 与 appid
730是csgo的appid
如果您使用 chrome
,我建议您获取 json 格式化程序
向下滚动您的库存,您会看到这个
我的部分库存
代码
//My steam inventory
$url = "http://steamcommunity.com/id/tonzapvp/inventory/json/730/2";
$json = json_decode(file_get_contents($url));
foreach($json->rgDescriptions as $value => $v){
// we cant know what value $v is because its different everytime
//that's why we are using '=>' after rgDescription
$name = $v->market_hash_name;
$icon_url = $v->icon_url;
//http://cdn.steamcommunity.com/economy/image/$icon_url
//echo this link in img src
echo "<img src='http://cdn.steamcommunity.com/economy/image/$icon_url'>"
echo $name;
}
你好,我只是想知道是否有办法检查
中的所有项目用户盘点并回显物品名称和物品图片,
我应该使用 rgInventory 还是 rgDescriptions?
我应该如何遍历它?
抱歉我很笨
您需要获取玩家 steam id
库存:
http://steamcommunity.com/profiles/steam_id/inventory/json/730/2
将 steam_id 替换为您的 steam id
和 730 与 appid
730是csgo的appid
如果您使用 chrome
,我建议您获取 json 格式化程序向下滚动您的库存,您会看到这个
我的部分库存
代码
//My steam inventory
$url = "http://steamcommunity.com/id/tonzapvp/inventory/json/730/2";
$json = json_decode(file_get_contents($url));
foreach($json->rgDescriptions as $value => $v){
// we cant know what value $v is because its different everytime
//that's why we are using '=>' after rgDescription
$name = $v->market_hash_name;
$icon_url = $v->icon_url;
//http://cdn.steamcommunity.com/economy/image/$icon_url
//echo this link in img src
echo "<img src='http://cdn.steamcommunity.com/economy/image/$icon_url'>"
echo $name;
}