Get CS:GO JSON item status

Asked

Viewed 179 times

-4

Good is the following I have the following code that causes you to take all items/weapons from the inventory of a particular individual and show it.

Well what I wanted to know is how do I do apart from picking up the items say the status of the item, like:

Sawed-Off | Full Stop (Field-Tested)

My Code:

<?php
$steamid = '76561198103888786';

$destUrl = 'http://steamcommunity.com/profiles/' . $steamid . '/inventory/json/730/2/';

$data = file_get_contents($destUrl, false);
$data = json_decode($data, true);
$data1= array_keys($data['rgDescriptions']);
$data2= $data['rgDescriptions'];
for($i = 0; $i < count($data1); ++$i) {
    $items =  $data2[$data1[$i]]['name'];
        echo $items;
        echo "<br>";
}
?>

1 answer

1

The mentioned item of example is the 310778159_302028390.

CS:GO API

That way, you should only get the market_hash_name or the market_name instead of name.

In this case simply insert:

for($i = 0; $i < count($data1); ++$i) {

    echo '<br> ID: '. $data1[$i];
    echo '<br> Name: '. $data2[$data1[$i]]['name'];
    echo '<br> Market_Hash_Name: '. $data2[$data1[$i]]['market_hash_name'];
    echo '<br> Market_Name: '. $data2[$data1[$i]]['market_name'];
    echo '<br>';

}

With this will get and display all the data both of the market_* both that of the name.

  • I could perfectly get all the items, now in the case how would I put each item in 1 variable in the case, $item1 = first item, $item2 = second item, $item3 = third item, how can I do this, so I can insert all the player’s items in the bd.?

  • There are several ways. I, today, would do so: $inventario[] = "(0, $usuario, $name, $market_hash, $market_name)", within the for. Then I would make a $valores = implode(',', $inventario). That way it would be enough to make a INSERT INTO tabela VALUES $valores. On test would stay: INSERT INTO tabela VALUES (0,1,2,3,4), (0,1,7,8,9), (0,1,3,4,5), for example. I answered a similar question without using the implode, but with the same idea in http://answall.com/questions/112798/como-fazer-v%C3%A1rios-registros-de-checkbox-no-banco-de-uma-s%C3%B3-vez/112809#112809.

  • Can you edit your answer with this to get more organized? Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.