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;
}

在那个链接上是我的项目,我想把它们的名字写在我的页面上。

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

谁能帮我选择代码的具体部分?

试试这个

$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'],希望这有助于。