Steam Achievements API - 如何获得成就解锁日期?

Akk*_*kki 4 steam-web-api steam

这可以在Steam Acheivements API中获得成就解锁日期吗?我已经阅读了一堆文档,但没有提到这一点.

And*_*ndy 7

答案是肯定的,但是你必须使用旧的XML API,而不是更新的Web API,它必须是一个"更新"的成就.

旧样式URL如下所示

http://steamcommunity.com/id/<profilename>/stats/<appid>/achievements/?xml=1
Run Code Online (Sandbox Code Playgroud)

要么

http://steamcommunity.com/profiles/<profileid>/stats/<appid>/achievements/?xml=1
Run Code Online (Sandbox Code Playgroud)

在这一点上有几个笔记:

  • <profilename>是用户选择的唯一URL名称.这<profileid>是Valve分配的唯一64位数
  • <appid>是数字应用程序ID.我假设你知道如何找到这个,对吗?

如果从该链接中提取XML,最终会得到如下所示的结构:

playerstats
  game
  player
  stats
  achievements
    achievement
      iconClosed
      iconOpened
      name
      apiname
      description
      unlockTimestamp
Run Code Online (Sandbox Code Playgroud)

重要提示:unlockTimestamp并非始终可用.如果没有深入研究它,似乎这是在较旧的游戏(即TF2)的情况下稍后添加的.因此,您有一些返回与此类似的数据的原始成就:

<achievement closed="1">
  <iconClosed>http://media.steampowered.com/steamcommunity/public/images/apps/440/tf_play_game_everyclass.jpg</iconClosed>
  <iconOpen>http://media.steampowered.com/steamcommunity/public/images/apps/440/tf_play_game_everyclass_bw.jpg</iconOpen>
  <name>Head of the Class</name>
  <apiname>tf_play_game_everyclass</apiname>
  <description>Play a complete round with every class.</description>
</achievement>
Run Code Online (Sandbox Code Playgroud)

与以下类似的新成就:

<achievement closed="1">
  <iconClosed>http://media.steampowered.com/steamcommunity/public/images/apps/440/bb590c7ca44dfc7eb6a31abb39fae07c47502ac7.jpg</iconClosed>
  <iconOpen>http://media.steampowered.com/steamcommunity/public/images/apps/440/4f244b30a76e9de5287a82cc3829c7930baa38c7.jpg</iconOpen>
  <name>Got A Light?</name>
  <apiname>tf_pyro_burn_spy_taunt</apiname>
  <description>Ignite an enemy Spy while he's flicking a cigarette.</description>
  <unlockTimestamp>1301887931</unlockTimestamp>
</achievement>
Run Code Online (Sandbox Code Playgroud)

如果玩家尚未获得成就,那么节点closed上的属性achievement将相等0,并且返回的数据看起来与旧的成就相似(没有unlockTimestamp)

<achievement closed="0">
  <iconClosed>http://media.steampowered.com/steamcommunity/public/images/apps/440/957daad8f6b9f237620e0326f38cbf941c60a9d1.jpg</iconClosed>
  <iconOpen>http://media.steampowered.com/steamcommunity/public/images/apps/440/34b787ce4e47ef0e206ecd52626b053da13e18c4.jpg</iconOpen>
  <name>Krazy Ivan</name>
  <apiname>tf_heavy_kill_underwater</apiname>
  <description>Kill 50 enemies while both you and your victim are underwater.</description>
</achievement>
Run Code Online (Sandbox Code Playgroud)

在上述XML结构中,achievement节点将针对所选游戏可用的每个成就重复.