获取Steam库存

时间:2015-11-09 13:04:05

标签: php json api steam inventory

我希望在网站上看到用户的广告资源。我获得了获取库存的功能CS:GO:

function getInventory($steamapi, $steamid, $userid) {
 }

$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$steamapi&steamids=$steamid";
$json_object = file_get_contents($url);
$json_decoded = json_decode($json_object);

$str = $json_decoded->response->players[0]->steamid;

$urlInv = "http://steamcommunity.com/profiles/" . $str . "/inventory/json/730/2/?trading=1";

$json_object_inv = file_get_contents($urlInv);
$json_decoded_inv = json_decode($json_object_inv, true);

$rgInventory = $json_decoded_inv[rgInventory];
$rgInventory = array_values($rgInventory);

$rgDesc = $json_decoded_inv[rgDescriptions];
$rgDesc = array_values($rgDesc);

$itemnames = array();

*******
}}

当我使用它时,我有这个麻烦:

Warning: array_values() expects parameter 1 to be array, null given in ***\functions.php on line 278 //this 20 string

Warning: array_values() expects parameter 1 to be array, null given in ***\functions.php on line 281 //this 23 string

这是什么? 谢谢。

1 个答案:

答案 0 :(得分:-1)

如果解码失败,json_decode将返回null:https://secure.php.net/manual/en/function.json-decode.php