1

堆栈溢出答案解释了如何检索用户的公共库存

http://steamcommunity.com/profiles/<PROFILEID>/inventory/json/<APPID>/<CONTEXTID>

我读到上下文 ID 必须设置为 2 才能找到大多数游戏的项目,但情况并非总是如此。是否有任何官方 API 来查找用户的库存上下文?steamapis.com 已经有一个付费的 API来执行这个任务:

{
    "steamID": {
        "universe": 1,
        "type": 1,
        "instance": 1,
        "accountid": 78261062
    },
    "name": "PEPZ",
    "onlineState": "online",
    "stateMessage": "Online",
    "privacyState": "public",
    "visibilityState": "3",
    "avatarHash": "5b702b331ddeb928225ad562a3e729aecd191b9a",
    "vacBanned": false,
    "tradeBanState": "None",
    "isLimitedAccount": false,
    "customURL": "pepzwee",
    "memberSince": "2011-02-21T22:00:00.000Z",
    "location": "Estonia",
    "realName": "SteamApis.com Developer",
    "summary": "",
    "groups": [
        {
            "universe": 1,
            "type": 7,
            "instance": 0,
            "accountid": 28077004
        },
        ...
    ],
    "primaryGroup": {
        "universe": 1,
        "type": 7,
        "instance": 0,
        "accountid": 28077004
    },
    "contexts": {
        "440": {
            "appid": 440,
            "name": "Team Fortress 2",
            "icon": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/440/e3f595a92552da3d664ad00277fad2107345f743.jpg",
            "link": "http://steamcommunity.com/app/440",
            "asset_count": 11,
            "inventory_logo": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/440/e613d1d46de26ea755105b898cc8830d305353f3.png",
            "trade_permissions": "FULL",
            "load_failed": 0,
            "rgContexts": {
                "2": {
                    "asset_count": 11,
                    "id": "2",
                    "name": "Backpack"
                }
            }
        },
        ...
    }
}

其中“rgContexts”包含每个游戏的库存上下文。

4

1 回答 1

0

我通过一些检查元素工作发现,有一个可用的脚本标签,其中包含您需要的确切信息。这是我的个人资料的一个例子:


var g_rgWalletInfo = {"success":false};
var g_bInventoryIsInModalDialog = false;
var g_bIsInMarketplace = false;

UserYou.SetSteamId( '76561199033382814' );

    var g_rgAppContextData = {"753":{"appid":753,"name":"Steam","icon":"https:\/\/cdn.cloudflare.steamstatic.com\/steamcommunity\/public\/images\/apps\/753\/135dc1ac1cd9763dfc8ad52f4e880d2ac058a36c.jpg","link":"https:\/\/steamcommunity.com\/app\/753","asset_count":303,"inventory_logo":"https:\/\/cdn.cloudflare.steamstatic.com\/steamcommunity\/public\/images\/apps\/753\/db8ca9e130b7b37685ab2229bf5a288aefc3f0fa.png","trade_permissions":"FULL","load_failed":0,"store_vetted":"1","rgContexts":{"6":{"asset_count":303,"id":"6","name":"Community"}}},"730":{"appid":730,"name":"Counter-Strike: Global Offensive","icon":"https:\/\/cdn.cloudflare.steamstatic.com\/steamcommunity\/public\/images\/apps\/730\/69f7ebe2735c366c65c0b33dae00e12dc40edbe4.jpg","link":"https:\/\/steamcommunity.com\/app\/730","asset_count":61,"inventory_logo":"https:\/\/cdn.cloudflare.steamstatic.com\/steamcommunity\/public\/images\/apps\/730\/3ab6e87a04994b900881f694284a75150e640536.png","trade_permissions":"FULL","load_failed":0,"store_vetted":"1","rgContexts":{"2":{"asset_count":61,"id":"2","name":"Backpack"}}}};
        var g_strInventoryLoadURL = 'https://steamcommunity.com/id/stoplookingatmyid/inventory/json/';
    $J( function() {
        UserYou.LoadContexts( g_rgAppContextData );
    } );

$J( function() {
    var bHasPendingGifts = false;
    InitInventoryPage( bHasPendingGifts, -1, false );
});
var g_bInClient = false;
var g_bInChinaRealm =  false;
var g_bViewingOwnProfile = false;
var g_bMarketAllowed = false;
var g_strLanguage = 'english';
var g_strCountryCode = "US";
var g_strProfileURL = 'https://steamcommunity.com/id/stoplookingatmyid';

其中一些数据是垃圾数据,但g_rgAppContextData正是您需要的 JSON 格式的数据,如果您选择的编程语言只需要对其进行解析。在这个例子中,753 是 的 app id Steam,6 是 context id,730 是CSGO'Sapp id,2 作为 context id。如果用户有私人 Steam 库存,则不会出现此数据。

于 2021-01-28T18:52:14.767 回答