Skip to content

Commit decf392

Browse files
committed
Dokumentation
1 parent f33aa23 commit decf392

7 files changed

Lines changed: 196 additions & 86 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace wcf\system\exception;
3+
4+
/**
5+
* Steam exception
6+
*
7+
* @author Peter Lohse <hanashi@hanashi.eu>
8+
* @copyright Hanashi Development
9+
* @license Freie Lizenz (https://hanashi.eu/freie-lizenz/)
10+
* @package WoltLabSuite\Core\System\Exception
11+
*/
12+
class SteamException extends SystemException {}
Lines changed: 142 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,187 @@
11
<?php
22
namespace wcf\system\steam;
3-
3+
use wcf\system\exception\SteamException;
4+
use wcf\util\HTTPRequest;
5+
use wcf\util\JSON;
6+
7+
/**
8+
* Steam Web Api class
9+
* api key can got from here: https://steamcommunity.com/dev/apikey
10+
* method documentation is from original documentations
11+
*
12+
* @see https://steamcommunity.com/dev
13+
* @see https://openid.net/specs/openid-authentication-2_0.html
14+
* @author Peter Lohse <hanashi@hanashi.eu>
15+
* @copyright Hanashi Development
16+
* @license Freie Lizenz (https://hanashi.dev/freie-lizenz/)
17+
* @package WoltLabSuite\Core\System\Steam
18+
*/
419
class SteamAPI {
5-
// TODO: Testschlüssel: 411C7A63AF279374C9D8554B898AC0B5
6-
// https://steamcommunity.com/dev/apikey
20+
/**
21+
* returns the latest news of a game specified by its appID
22+
*
23+
* @var int $appID AppID of the game you want the news of.
24+
* @var int $count (optional) How many news enties you want to get returned.
25+
* @var int $maxLength (optional) Maximum length of each news entry.
26+
* @return array latest news of a game
27+
*/
28+
public static function getNewsForApp(int $appID, int $count = null, int $maxLength = null) : array {
729

8-
// https://steamcommunity.com/dev?l=german
30+
}
931

10-
public static function getNewsForApp($appID, $count = 10, $maxLength = 300) {
32+
/**
33+
* returns global achievements overview of a specific game in percentages
34+
*
35+
* @var int $appID AppID of the game you want the percentages of.
36+
* @return array global achievements overview of a specific game in percentages
37+
*/
38+
public static function getGlobalAchievmentPercentagesForApp(int $appID) : array {
1139

1240
}
1341

14-
public static function getGlobalAchievmentPercentagesForApp($appID) {
42+
/**
43+
* returns global stats of a specific game
44+
*
45+
* @var int $appID AppID of the game you want the stats of
46+
* @var array $names Name of the achievement as defined in Steamworks. (name[0] [and name[1], etc.])
47+
* @var int $count Length of the array of global stat names you will be passing.
48+
* @return array global stats of a specific game
49+
*/
50+
public static function getGlobalStatsForGame(int $appID, array $names, int $count = 1) : array {
1551

1652
}
1753

18-
public static function getGlobalStatsForGame($appID, $names, $count = 1) {
54+
/**
55+
* returns basic profile information for a list of 64-bit Steam IDs
56+
*
57+
* @var array $steamIDs List of 64 bit Steam IDs to return profile information for. Up to 100 Steam IDs can be requested.
58+
* @return array basic profile information for a list of 64-bit Steam IDs (Some data associated with a Steam account may be hidden if the user has their profile visibility set to "Friends Only" or "Private". In that case, only public data will be returned.)
59+
*/
60+
public static function getPlayerSummaries(array $steamIDs) : array {
1961

2062
}
2163

22-
public static function getPlayerSummaries($steamIDs) {
64+
/**
65+
* returns the friend list of any Steam user, provided their Steam Community profile visibility is set to "Public"
66+
*
67+
* @var int $steamID 64 bit Steam ID to return friend list for
68+
* @var string $relationShip Relationship filter. Possibles values: all, friend
69+
* @return array friend list of any Steam user, provided their Steam Community profile visibility is set to "Public"
70+
*/
71+
public static function getFriendList(int $steamID, string $relationShip = 'friend') : array {
2372

2473
}
2574

26-
public static function getFriendList($steamID, $relationShip = 'friend') {
75+
/**
76+
* returns a list of achievements for this user by app id
77+
*
78+
* @var int $steamID 64 bit Steam ID to return achievements for.
79+
* @var int $appID The ID for the game you're requesting
80+
* @var string $language (optional) Language. If specified, it will return language data for the requested language.
81+
* @return array list of achievements for this user by app id
82+
*/
83+
public static function getPlayerAchievments(int $steamID, int $appID, string $language = null) : array {
2784

2885
}
2986

30-
public static function getPlayerAchievments($steamID, $appID, $language = null) {
87+
/**
88+
* returns a list of stats for this user by app id
89+
*
90+
* @var int $steamID 64 bit Steam ID to return stats for.
91+
* @var int $appID The ID for the game you're requesting
92+
* @var string $language (optional) Language. If specified, it will return language data for the requested language.
93+
* @return array list of stats for this user by app id
94+
*/
95+
public static function getUserStatsForGame(int $steamID, int $appID, string $language = null) : array {
3196

3297
}
3398

34-
public static function getUserStatsForGame($steamID, $appID, $language = null) {
99+
/**
100+
* returns a list of games a player owns along with some playtime information, if the profile is publicly visible. Private, friends-only, and other privacy settings are not supported unless you are asking for your own personal details (ie the WebAPI key you are using is linked to the steamid you are requesting).
101+
*
102+
* @var int $steamID The SteamID of the account.
103+
* @var bool $includeAppInfo (optional) Include game name and logo information in the output. The default is to return appids only.
104+
* @var bool $includeFreeGames (optional) By default, free games like Team Fortress 2 are excluded (as technically everyone owns them). If include_played_free_games is set, they will be returned if the player has played them at some point. This is the same behavior as the games list on the Steam Community.
105+
* @var array $appIDs (optional) You can optionally filter the list to a set of appids.
106+
* @return array list of games a player owns along with some playtime information
107+
*/
108+
public static function getOwnedGames(int $steamID, bool $includeAppInfo = true, bool $includeFreeGames = false, array $appIDs = []) : array {
35109

36110
}
37111

38-
public static function getOwnedGames($steamID, $includeAppInfo = true, $includeFreeGames = false, $appIDs = []) {
112+
/**
113+
* returns a list of games a player has played in the last two weeks, if the profile is publicly visible. Private, friends-only, and other privacy settings are not supported unless you are asking for your own personal details (ie the WebAPI key you are using is linked to the steamid you are requesting).
114+
*
115+
* @var int $steamID The SteamID of the account.
116+
* @var int $count (optional) Optionally limit to a certain number of games (the number of games a person has played in the last 2 weeks is typically very small)
117+
* @return array list of games a player has played in the last two weeks
118+
*/
119+
public static function getRecentlyPlayedGames(int $steamID, int $count = null) : array {
39120

40121
}
41122

42-
public static function getRecentlyPlayedGames($steamID, $count = null) {
123+
/**
124+
* returns the original owner's SteamID if a borrowing account is currently playing this game. If the game is not borrowed or the borrower currently doesn't play this game, the result is always 0.
125+
*
126+
* @var int $steamID The SteamID of the account playing.
127+
* @var int $appIDPlaying The AppID of the game currently playing
128+
* @return int original owner's SteamID if a borrowing account is currently playing this game
129+
*/
130+
public static function isPlayingSharedGame(int $steamID, int $appIDPlaying) : int {
43131

44132
}
45133

46-
public static function isPlayingSharedGame($steamID, $appIDPlaying) {
134+
/**
135+
* returns gamename, gameversion and availablegamestats (achievements and stats).
136+
*
137+
* @var int $appID The AppID of the game you want stats of
138+
* @var string $language (optional) Language. If specified, it will return language data for the requested language.
139+
* @return array gamename, gameversion and availablegamestats (achievements and stats).
140+
*/
141+
public static function getSchemaForGame(int $appID, string $language = null) : array {
47142

48143
}
49144

50-
public static function getSchemaForGame($appID, $language = null) {
145+
/**
146+
* returns Community, VAC, and Economy ban statuses for given players.
147+
*
148+
* @var array list of SteamIDs
149+
* @return array Community, VAC, and Economy ban statuses for given players
150+
*/
151+
public static function getPlayerBans(array $steamIDs) : array {
51152

52153
}
53154

54-
public static function getPlayerBans($steamIDs) {
55-
155+
/**
156+
* get OpenID login url
157+
*
158+
* @var string $redirectUri URL to which the OP SHOULD return the User-Agent with the response indicating the status of the request.
159+
* @var string $realm URL pattern the OP SHOULD ask the end user to trust.
160+
* @return string
161+
*/
162+
public static function getOpenIDUrl(string $redirectUri, string $realm) : string {
163+
$data = [
164+
'openid.ns' => 'http://specs.openid.net/auth/2.0',
165+
'openid.mode' => 'checkid_setup',
166+
'openid.return_to' => $redirectUri,
167+
'openid.realm' => $realm,
168+
'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select',
169+
'openid.identity' => 'http://specs.openid.net/auth/2.0/identifier_select'
170+
];
171+
return 'https://steamcommunity.com/openid/login?' . http_build_query($data, null, '&');
56172
}
57173

58-
// openID
59-
// https://openid.net/specs/openid-authentication-2_0.html
174+
/**
175+
* validate OpenID data and returns SteamID
176+
*
177+
* @var array $data content of $_GET by redirect uri, where prefix is "openid."
178+
* @return int 64 bit of SteamID
179+
*/
180+
public static function validateOpenID(array $data) : int {
60181

61-
public static function getOpenIDUrl($redirectUri, $realm) {
62-
// https://steamcommunity.com/openid/login?openid.ns=http://specs.openid.net/auth/2.0&openid.mode=checkid_setup&openid.return_to=https://hanashi.dev/steam/test.php&openid.realm=https://hanashi.dev&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select
63182
}
64183

65-
public static function validateOpenID() {
66-
// https://hanashi.dev/steam/test.php?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Flogin&openid.claimed_id=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F76561198049434265&openid.identity=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F76561198049434265&openid.return_to=https%3A%2F%2Fhanashi.dev%2Fsteam%2Ftest.php&openid.response_nonce=2020-01-21T12%3A41%3A54Zc4Xs%2BIFl6Up6Sr8JdU84JV4Y2n4%3D&openid.assoc_handle=1234567890&openid.signed=signed%2Cop_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle&openid.sig=GbKmtwudO%2B9WOUtvttG%2FZMFF0ts%3D
184+
protected static function execute($url, $data) {
185+
67186
}
68187
}

language/de.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<language xmlns="https://www.woltlab.com" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.woltlab.com https://www.woltlab.com/XSD/vortex/language.xsd" languagecode="de">
3-
<category name="wcf.acl.option">
4-
<item name="wcf.acl.option.com.woltlab.wbb.board.canStartRaffle"><![CDATA[Kann Gewinnspiel starten]]></item>
5-
<item name="wcf.acl.option.com.woltlab.wbb.board.canParticipantRaffle"><![CDATA[Kann an Gewinnspiel teilnehmen]]></item>
2+
<language xmlns="https://www.woltlab.com" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.woltlab.com https://www.woltlab.com/XSD/2019/language.xsd" languagecode="de">
3+
<category name="wcf.acp.option">
4+
<item name="wcf.acp.option.category.steam"><![CDATA[Steam]]></item>
5+
<item name="wcf.acp.option.category.steam.api"><![CDATA[API]]></item>
6+
<item name="wcf.acp.option.steam_api_key"><![CDATA[Web-API-Schlüssel]]></item>
7+
<item name="wcf.acp.option.steam_api_key.description"><![CDATA[Vor der Benutzung der Steam-API muss der API-Schlüssel eingefügt werden. Der API-Schlüssel kann <a href="https://steamcommunity.com/dev/apikey" rel="nofollow"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>hier</a> abgerufen werden.]]></item>
8+
</category>
9+
<category name="wcf.acp.group">
10+
<item name="wcf.acp.group.option.category.user.steam"><![CDATA[Steam]]></item>
11+
<item name="wcf.acp.group.option.category.mod.steam"><![CDATA[Steam]]></item>
12+
<item name="wcf.acp.group.option.category.admin.steam"><![CDATA[Steam]]></item>
613
</category>
714
</language>

language/en.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<language xmlns="https://www.woltlab.com" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.woltlab.com https://www.woltlab.com/XSD/2019/language.xsd" languagecode="en">
3+
<category name="wcf.acp.option">
4+
<item name="wcf.acp.option.category.steam"><![CDATA[Steam]]></item>
5+
<item name="wcf.acp.option.category.steam.api"><![CDATA[API]]></item>
6+
<item name="wcf.acp.option.steam_api_key"><![CDATA[Web API Key]]></item>
7+
<item name="wcf.acp.option.steam_api_key.description"><![CDATA[Before using the Steam API, the API key must be inserted. The API key can be retrieved <a href="https://steamcommunity.com/dev/apikey" rel="nofollow"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>here</a>.]]></item>
8+
</category>
9+
<category name="wcf.acp.group">
10+
<item name="wcf.acp.group.option.category.user.steam"><![CDATA[Steam]]></item>
11+
<item name="wcf.acp.group.option.category.mod.steam"><![CDATA[Steam]]></item>
12+
<item name="wcf.acp.group.option.category.admin.steam"><![CDATA[Steam]]></item>
13+
</category>
14+
</language>

option.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<data xmlns="https://www.woltlab.com" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.woltlab.com https://www.woltlab.com/XSD/tornado/option.xsd">
2+
<data xmlns="https://www.woltlab.com" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.woltlab.com https://www.woltlab.com/XSD/2019/option.xsd">
33
<import>
44
<categories>
5-
<category name="raffle">
5+
<category name="steam">
66
<parent />
77
</category>
8-
<category name="raffle.general">
9-
<parent>raffle</parent>
8+
<category name="steam.api">
9+
<parent>steam</parent>
1010
</category>
1111
</categories>
1212
<options>
13-
<option name="hanashi_raffle_show_box_always">
14-
<categoryname>raffle.general</categoryname>
15-
<optiontype>boolean</optiontype>
16-
<defaultvalue>1</defaultvalue>
13+
<option name="steam_api_key">
14+
<categoryname>steam.api</categoryname>
15+
<optiontype>string</optiontype>
16+
<!-- TODO: delete key -->
17+
<defaultvalue>411C7A63AF279374C9D8554B898AC0B5</defaultvalue>
1718
</option>
1819
</options>
1920
</import>

package.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
<instruction type="file" />
2828

2929
<!-- language -->
30-
<!-- <instruction type="language"/> -->
30+
<instruction type="language"/>
3131

3232
<!-- config -->
33-
<!-- <instruction type="userGroupOption" /> -->
34-
<!-- <instruction type="option" /> -->
33+
<instruction type="userGroupOption" />
34+
<instruction type="option" />
3535
</instructions>
3636
</package>

userGroupOption.xml

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<data xmlns="https://www.woltlab.com" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.woltlab.com https://www.woltlab.com/XSD/tornado/userGroupOption.xsd">
2+
<data xmlns="https://www.woltlab.com" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.woltlab.com https://www.woltlab.com/XSD/2019/userGroupOption.xsd">
33
<import>
44
<categories>
5-
<category name="user.raffle">
5+
<category name="user.steam">
66
<parent>user</parent>
77
</category>
8-
<category name="user.board.raffle">
9-
<parent>user.board</parent>
8+
<category name="mod.steam">
9+
<parent>mod</parent>
1010
</category>
11-
<category name="admin.raffle">
11+
<category name="admin.steam">
1212
<parent>admin</parent>
1313
</category>
1414
</categories>
15-
<options>
16-
<option name="user.board.canParticipantRaffle">
17-
<categoryname>user.board.raffle</categoryname>
18-
<optiontype>boolean</optiontype>
19-
<defaultvalue>0</defaultvalue>
20-
<userdefaultvalue>1</userdefaultvalue>
21-
</option>
22-
<option name="user.board.canStartRaffle">
23-
<categoryname>user.board.raffle</categoryname>
24-
<optiontype>boolean</optiontype>
25-
<defaultvalue>0</defaultvalue>
26-
<userdefaultvalue>1</userdefaultvalue>
27-
</option>
28-
<option name="user.board.canManageTerms">
29-
<categoryname>user.board.raffle</categoryname>
30-
<optiontype>boolean</optiontype>
31-
<defaultvalue>0</defaultvalue>
32-
<moddefaultvalue>1</moddefaultvalue>
33-
</option>
34-
<option name="user.raffle.canShowGlobalRaffle">
35-
<categoryname>user.raffle</categoryname>
36-
<optiontype>boolean</optiontype>
37-
<defaultvalue>1</defaultvalue>
38-
</option>
39-
<option name="user.raffle.canParticipantGlobalRaffle">
40-
<categoryname>user.raffle</categoryname>
41-
<optiontype>boolean</optiontype>
42-
<defaultvalue>0</defaultvalue>
43-
<userdefaultvalue>1</userdefaultvalue>
44-
</option>
45-
<option name="user.raffle.canShowParticipants">
46-
<categoryname>user.raffle</categoryname>
47-
<optiontype>boolean</optiontype>
48-
<defaultvalue>0</defaultvalue>
49-
<moddefaultvalue>1</moddefaultvalue>
50-
</option>
51-
<option name="admin.raffle.canManageRaffle">
52-
<categoryname>admin.raffle</categoryname>
53-
<optiontype>boolean</optiontype>
54-
<defaultvalue>0</defaultvalue>
55-
<admindefaultvalue>1</admindefaultvalue>
56-
</option>
57-
</options>
5815
</import>
5916
</data>

0 commit comments

Comments
 (0)