Answer the question
In order to leave comments, you need to log in
How to display prices from the parser?
Hello everyone, I have this question:
the code of the parser of things:
public function loadMyInventory() {
if(Auth::guest()) return ['success' => false];
$prices = json_decode(File::get('prices.txt'), true);
if (Session::get('applocale') == 'ru') {
$response = json_decode(file_get_contents('https://steamcommunity.com/inventory/'.$this->user->steamid64.'/730/2?l=russian&count=5000'), true);
} else {
$response = json_decode(file_get_contents('https://steamcommunity.com/inventory/'.$this->user->steamid64.'/730/2?l=english&count=5000'), true);
}
if(time() < (Session::get('InvUPD') + 5)) {
return [
'success' => false,
'msg' => 'Произошла ошибка. Повторите через '.(Session::get('InvUPD') - time() + 5).' сек.',
'status' => 'error'
];
}
//return $response;
$inventory = [];
foreach($response['assets'] as $item) {
$find = 0;
foreach($response['descriptions'] as $descriptions) {
if($find == 0) {
if(($descriptions['classid'] == $item['classid']) && ($descriptions['instanceid'] == $item['instanceid'])) {
$find++;
# Если мы нашли цену на итем, то идем дальше.
if(isset($prices['data']['prices'][0]['market_hash_name'])) {
# Поиск данных
$price = $prices['data']['prices'][0]['price']*$this->config->curs;
$class = false;
$text = false;
if($price <= $this->config->min_dep_sum) {
$price = 0;
if (Session::get('applocale') == 'ru') {
$text = 'Дешевое';
} else {
$text = 'Cheap';
}
$class = 'minPrice';
}
if(($descriptions['tradable'] == 0) || ($descriptions['marketable'] == 0)) {
$price = 0;
$class = 'minPrice';
if (Session::get('applocale') == 'ru') {
$text = 'Нельзя передавать';
} else {
$text = 'Not tradable';
}
}
# Добавление в массив
$inventory[] = [
'name' => $descriptions['market_name'],
'price' => floor($price),
'color' => $this->getRarity($descriptions['tags']),
'tradable' => $descriptions['tradable'],
'class' => $class,
'text' => $text,
'classid' => $item['classid'],
'assetid' => $item['assetid'],
'instanceid' => $item['instanceid']
];
}
}
}
}
}
Session::put('InvUPD', (time() + 5));
return [
'success' => true,
'items' => $inventory
];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question