My code is here:
case 'get_inv':
if(!$user) exit(json_encode(array('success'=>false, 'error'=>'You must login to access the deposit.')));
if((file_exists('cache/'.$user['steamid'].'.txt')) && (!isset($_GET['nocache']))) {
$array = file_get_contents('cache/'.$user['steamid'].'.txt');
$array = unserialize($array);
$array['fromcache'] = true;
if(isset($_COOKIE['tid'])) {
$sql = $db->query('SELECT * FROM `trades` WHERE `id` = '.$db->quote($_COOKIE['tid']).' AND `status` = 0');
if($sql->rowCount() != 0) {
$row = $sql->fetch();
$array['code'] = $row['code'];
$array['amount'] = $row['summa'];
$array['tid'] = $row['id'];
$array['bot'] = "Bot #".$row['bot_id'];
} else {
setcookie("tid", "", time() - 3600, '/');
}
}
exit(json_encode($array));
}
$prices = file_get_contents('prices.txt');
$prices = json_decode($prices, true);
$inv = file_get_contents('https://steamcommunity.com/profiles/'.$user['steamid'].'/inventory/json/730/2/');
$inv = json_decode($inv, true);
if($inv['success'] != 1) {
exit(json_encode(array('error'=>'Your profile is private. Please <a href="http://steamcommunity.com/my/edit/settings" target="_blank">set your inventory to public</a> and <a href="javascript:loadLeft('nocache')">try again</a>.')));
}
$items = array();
foreach ($inv['rgInventory'] as $key => $value) {
$id = $value['classid'].'_'.$value['instanceid'];
$trade = $inv['rgDescriptions'][$id]['tradable'];
if(!$trade) continue;
$name = $inv['rgDescriptions'][$id]['market_hash_name'];
$price = $prices['response']['items'][$name]['value']*0.9;
$img = 'http://steamcommunity-a.akamaihd.net/economy/image/'.$inv['rgDescriptions'][$id]['icon_url'];
if((preg_match('/(Souvenir)/', $name)) || ($price < $min)) {
$price = 0;
$reject = 'Junk';
} else {
$reject = 'unknown item';
}
$items[] = array(
'assetid' => $value['id'],
'bt_price' => "0.00",
'img' => $img,
'name' => $name,
'price' => $price,
'reject' => $reject,
'sa_price' => $price,
'steamid' => $user['steamid']);
}
$array = array(
'error' => 'none',
'fromcache' => false,
'items' => $items,
'success' => true);
if(isset($_COOKIE['tid'])) {
$sql = $db->query('SELECT * FROM `trades` WHERE `id` = '.$db->quote($_COOKIE['tid']).' AND `status` = 0');
if($sql->rowCount() != 0) {
$row = $sql->fetch();
$array['code'] = $row['code'];
$array['amount'] = $row['summa'];
$array['tid'] = $row['id'];
$array['bot'] = "Bot #".$row['bot_id'];
} else {
setcookie("tid", "", time() - 3600, '/');
}
}
file_put_contents('cache/'.$user['steamid'].'.txt', serialize($array), LOCK_EX);
exit(json_encode($array));
break;
I am trying to get people steam csgo inventory and put into an array. This works perfectly. Could someone help me figure out how to add a not tradeable tag. My plan is to add the item to the array even if not tradeable. I currently have it so if the item isnt worth < $0.30 then call it junk and ignore the press when clicked on. So something like if (!tradable) then mark as "trade locked" and ignore the press. Thank you.
question from:
https://stackoverflow.com/questions/65936603/csgo-steam-api-how-to-fetch-both-tradeable-and-non-tradeable-items-into-array 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…