通过API访问Steam社区组

时间:2014-01-05 11:17:37

标签: php api vbulletin steam

我正在尝试在论坛上运行Steam社区组的显示事件(运行vBulletin 4.2.1)。我查看了Steam API,我找不到任何可以访问群组的内容,他们似乎能够做的最多就是显示成员列表。

是否有允许您检索蒸汽组事件的API?还是有另一种方法可以做到这一点?

1 个答案:

答案 0 :(得分:5)

此(尚未)没有API,但您可以通过Valve提供的XML获取此信息。

首先,您需要知道您的论坛的groupID64值。您可以通过检查组成员的XML来找到它。

Robin Walker为例,我们可以使用以下网址查看他的个人资料:

http://steamcommunity.com/id/robinwalker/?xml=1

在该XML中,您会发现他是多个组的成员。每个人都有这样的一行:

<groupID64>103582791429521412</groupID64>

这个价值是我们所需要的。该值在此类URL中用于按月提取事件

 http://steamcommunity.com/gid/103582791429521412/events?xml=1&action=eventFeed&month=$month&year=$year

其中$month$year是数值(即2014年1月的12014

如果当月没有事件,这将返回看起来像这样的XML:

<response>
    <results>OK</results>
    <bPastMonth>0</bPastMonth>
    <monthName>January</monthName>
    <year>2014</year>
    <eventCount>0</eventCount>
    <expiredEventCount>0</expiredEventCount>
</response>

或者对于过期的事件:

<response>
    <results>OK</results>
    <bPastMonth>1</bPastMonth>
    <monthName>December</monthName>
    <year>2013</year>
    <expiredEvent eventID="1387405180685446058">                <div class="eventBlock" id="1387405180685446058_eventBlock">
                    <div class="eventLeftBlock">&nbsp;</div>
                    <div class="eventDateBlock"><span class="hiliteTextRed">Sunday 22</span><br /><span class="eventDateTime">10:26am</span></div>
                    <div class="eventBlockIcon">
                        <div class="playerAvatar"><a href="http://steamcommunity.com/groups/tf2scrap#events/1387405180685446058"><img src="http://media.steampowered.com/steamcommunity/public/images/apps/440/e3f595a92552da3d664ad00277fad2107345f743.jpg" /></a></div>
                    </div>
                    <div class="eventBlockTitle"><a class="headlineLink" href="http://steamcommunity.com/groups/tf2scrap#events/1387405180685446058">Christmas Event!</a><br />
                        <span class="eventSmallText"></span>
                    <a href="http://steamcommunity.com/groups/tf2scrap#events/1387405180685446058">280 comments...</a>
                    </div>
                    <br clear="left" />
                </div></expiredEvent>
    <eventCount>0</eventCount>
    <expiredEventCount>1</expiredEventCount></response>

或者即将发生的事件:

<response>
    <results>OK</results>
    <bPastMonth>0</bPastMonth>
    <monthName>January</monthName>
    <year>2014</year><event eventID="1371642583203021771">              <div class="eventBlock" id="1371642583203021771_eventBlock">
                <div class="eventLeftBlock">&nbsp;</div>
                <div class="eventDateBlock"><span class="">Friday 10</span><br /><span class="eventDateTime">11:00am</span></div>
                <div class="eventBlockIcon">
                    <div class="playerAvatar"><a href="http://steamcommunity.com/groups/steamlug#events/1371642583203021771"><img src="http://cdn.steamcommunity.com/public/images/skin_1/eventIcon_ChatEvent.jpg" /></a></div>
                </div>
                <div class="eventBlockTitle"><a class="headlineLink" href="http://steamcommunity.com/groups/steamlug#events/1371642583203021771">SteamLUG Cast S02E01</a><br />
                    <span class="eventSmallText"></span>
                <a href="http://steamcommunity.com/groups/steamlug#events/1371642583203021771">0 comments...</a>
                </div>
                <br clear="left" />
            </div></event>
    <eventCount>1</eventCount>
    <expiredEventCount>0</expiredEventCount>
</response>

eventexpiredEvent可以位于相同的XML中,eventCountexpiredEventCount将反映XML中显示的每个XML的总数。