Steam API 加载项目 json

Steam API load the items json

大家好,我开始尝试使用 Steam API 并且我已经完成登录...但是我在获取物品时遇到了一个大问题。我找不到我做错的解决方案。

$GetClientSteamItemsUrl = " http://steamcommunity.com/profiles/" . $_SESSION['steam_steamid'] . "/inventory/json/730/2";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $GetClientSteamItemsUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 3);
$output = curl_exec($ch);
$ArrayInventory = json_decode($output, true);
foreach($ArrayInventory['rgDescriptions'] as $inventory)
{
    echo $inventory;
}

上面 link 是我的项目,我想在我的页面上写下他们的名字。

错误:警告:为 /data/web/virtuals/112855/virtual/www/subdom/ayy/index 中的 foreach() 提供的参数无效。php

有人可以帮我 select 代码的特定部分吗?

试试这个

$inventory = file_get_contents("http://steamcommunity.com/profiles/".$_SESSION['steamid']."/inventory/json/730/2");
$myarrayInv = json_decode($inventory, true);  
foreach($myarrayInv['rgDescriptions'] as $item) 
{
echo $item['name']; 

}

如果你想 icon_url 等做 $item['icon_url'],希望这对你有帮助。