|
1 | 1 | <?php |
2 | 2 | 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 | + */ |
4 | 19 | 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 { |
7 | 29 |
|
8 | | - // https://steamcommunity.com/dev?l=german |
| 30 | + } |
9 | 31 |
|
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 { |
11 | 39 |
|
12 | 40 | } |
13 | 41 |
|
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 { |
15 | 51 |
|
16 | 52 | } |
17 | 53 |
|
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 { |
19 | 61 |
|
20 | 62 | } |
21 | 63 |
|
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 { |
23 | 72 |
|
24 | 73 | } |
25 | 74 |
|
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 { |
27 | 84 |
|
28 | 85 | } |
29 | 86 |
|
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 { |
31 | 96 |
|
32 | 97 | } |
33 | 98 |
|
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 { |
35 | 109 |
|
36 | 110 | } |
37 | 111 |
|
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 { |
39 | 120 |
|
40 | 121 | } |
41 | 122 |
|
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 { |
43 | 131 |
|
44 | 132 | } |
45 | 133 |
|
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 { |
47 | 142 |
|
48 | 143 | } |
49 | 144 |
|
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 { |
51 | 152 |
|
52 | 153 | } |
53 | 154 |
|
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, '&'); |
56 | 172 | } |
57 | 173 |
|
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 { |
60 | 181 |
|
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 |
63 | 182 | } |
64 | 183 |
|
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 | + |
67 | 186 | } |
68 | 187 | } |
0 commit comments