1 | <?php |
||
9 | class User extends Client |
||
10 | { |
||
11 | private $friendRelationships = [ |
||
12 | 'all', |
||
13 | 'friend', |
||
14 | ]; |
||
15 | |||
16 | 8 | public function __construct($steamId) |
|
22 | |||
23 | /** |
||
24 | * Get the user_ids for a display name. |
||
25 | * |
||
26 | * @param null $displayName Custom name from steam profile link. |
||
27 | * |
||
28 | * @return mixed |
||
29 | * |
||
30 | * @throws UnrecognizedId |
||
31 | */ |
||
32 | 2 | public function ResolveVanityURL($displayName = null) |
|
33 | { |
||
34 | // This only works with a display name. Make sure we have one. |
||
35 | 2 | if ($displayName == null) { |
|
36 | 1 | throw new UnrecognizedId('You must pass a display name for this call.'); |
|
37 | } |
||
38 | |||
39 | // Set up the api details |
||
40 | 1 | $this->method = __FUNCTION__; |
|
41 | 1 | $this->version = 'v0001'; |
|
42 | |||
43 | 1 | $results = $this->setUpClient(['vanityurl' => $displayName])->response; |
|
44 | |||
45 | // The message key is used when something goes wrong. If it exists, return it. |
||
46 | 1 | if (isset($results->message)) { |
|
47 | return $results->message; |
||
48 | } |
||
49 | |||
50 | // Return the full steam ID object for the display name. |
||
51 | 1 | return $this->convertId($results->steamid); |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param string $steamId |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | 2 | public function GetPlayerSummaries($steamId = null) |
|
60 | { |
||
61 | // Set up the api details |
||
62 | 2 | $this->method = __FUNCTION__; |
|
63 | 2 | $this->version = 'v0002'; |
|
64 | |||
65 | 2 | if ($steamId == null) { |
|
|
|||
66 | $steamId = $this->steamId; |
||
67 | } |
||
68 | |||
69 | 2 | $steamId = implode(',', (array)$steamId); |
|
70 | |||
71 | 2 | $chunks = array_chunk(explode(',', $steamId), 100); |
|
72 | |||
73 | 2 | $map = array_map([$this, 'getChunkedPlayerSummaries'], $chunks); |
|
74 | |||
75 | 2 | $players = $this->compressPlayerSummaries($map); |
|
76 | |||
77 | 2 | return $players; |
|
78 | } |
||
79 | |||
80 | 2 | private function getChunkedPlayerSummaries($chunk) |
|
95 | |||
96 | 2 | private function compressPlayerSummaries($summaries) |
|
107 | |||
108 | 2 | public function GetPlayerBans($steamId = null) |
|
128 | |||
129 | 2 | public function GetFriendList($relationship = 'all', $summaries = true) |
|
163 | |||
164 | 2 | protected function convertToObjects($players) |
|
176 | } |
||
177 |