【问题标题】:Get Steam inventory获取 Steam 库存
【发布时间】:2015-11-09 13:04:05
【问题描述】:

我想查看站点中的用户库存。我获得了获取库存 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();

*******
}}

当我使用这个时,我遇到了这个问题:

警告:array_values() 期望参数 1 是数组,在第 278 行的 ***\functions.php //this 20 字符串中给出 null

警告:array_values() 期望参数 1 为数组,在第 281 行的 ***\functions.php //this 23 字符串中给出 null

这是什么?

【问题讨论】:

    标签: php json steam


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-01
      • 2014-11-16
      • 2013-06-27
      • 2014-11-04
      • 2017-01-01
      • 1970-01-01
      相关资源
      最近更新 更多