1 | <?php |
||
10 | class User extends Client |
||
11 | { |
||
12 | private $friendRelationships = [ |
||
13 | 'all', |
||
14 | 'friend', |
||
15 | ]; |
||
16 | |||
17 | 3 | public function __construct($steamId) |
|
23 | |||
24 | /** |
||
25 | * Get the user_ids for a display name. |
||
26 | * |
||
27 | * @param null $displayName Custom name from steam profile link. |
||
28 | * |
||
29 | * @return mixed |
||
30 | * |
||
31 | * @throws UnrecognizedId |
||
32 | */ |
||
33 | 1 | public function ResolveVanityURL($displayName = null) |
|
34 | { |
||
35 | // This only works with a display name. Make sure we have one. |
||
36 | 1 | if ($displayName == null) { |
|
37 | 1 | throw new UnrecognizedId('You must pass a display name for this call.'); |
|
38 | } |
||
39 | |||
40 | // Set up the api details |
||
41 | $this->method = __FUNCTION__; |
||
42 | $this->version = 'v0001'; |
||
43 | |||
44 | $results = $this->setUpClient(['vanityurl' => $displayName])->response; |
||
45 | |||
46 | // The message key is used when something goes wrong. If it exists, return it. |
||
47 | if (isset($results->message)) { |
||
48 | return $results->message; |
||
49 | } |
||
50 | |||
51 | // Return the full steam ID object for the display name. |
||
52 | return $this->convertId($results->steamid); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param string $steamId |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | public function GetPlayerSummaries($steamId = null) |
||
78 | |||
79 | private function getChunkedPlayerSummaries($chunk) |
||
92 | |||
93 | private function compressPlayerSummaries($summaries) |
||
104 | |||
105 | public function GetPlayerBans($steamId = null) |
||
125 | |||
126 | 1 | public function GetFriendList($relationship = 'all', $summaries = true) |
|
127 | { |
||
128 | // Set up the api details |
||
129 | 1 | $this->method = __FUNCTION__; |
|
130 | 1 | $this->version = 'v0001'; |
|
131 | |||
132 | 1 | if (! in_array($relationship, $this->friendRelationships)) { |
|
133 | 1 | throw new InvalidArgumentException('Provided relationship [' . $relationship . '] is not valid. Please select from: ' . implode(', ', $this->friendRelationships)); |
|
134 | } |
||
135 | |||
136 | // Set up the arguments |
||
137 | $arguments = [ |
||
138 | 'steamid' => $this->steamId, |
||
139 | 'relationship' => $relationship, |
||
140 | ]; |
||
141 | |||
142 | // Get the client |
||
143 | $client = $this->setUpClient($arguments)->friendslist; |
||
144 | |||
145 | // Clean up the games |
||
146 | $steamIds = []; |
||
147 | |||
148 | foreach ($client->friends as $friend) { |
||
149 | $steamIds[] = $friend->steamid; |
||
150 | } |
||
151 | |||
152 | if($summaries) { |
||
153 | $friends = $this->GetPlayerSummaries(implode(',', $steamIds)); |
||
154 | } else { |
||
155 | $friends = $steamIds; |
||
156 | } |
||
157 | |||
158 | return $friends; |
||
159 | } |
||
160 | |||
161 | protected function convertToObjects($players) |
||
173 | } |
||
174 |