|
1
|
|
|
<?php namespace Syntax\SteamApi\Steam; |
|
2
|
|
|
|
|
3
|
|
|
use Syntax\SteamApi\Client; |
|
4
|
|
|
use Syntax\SteamApi\Collection; |
|
5
|
|
|
use Syntax\SteamApi\Containers\Game; |
|
6
|
|
|
use Syntax\SteamApi\Containers\Player\Level; |
|
7
|
|
|
|
|
8
|
|
|
class Player extends Client { |
|
9
|
|
|
|
|
10
|
|
|
public function __construct($steamId) |
|
11
|
|
|
{ |
|
12
|
|
|
parent::__construct(); |
|
13
|
|
|
$this->interface = 'IPlayerService'; |
|
14
|
|
|
$this->isService = true; |
|
15
|
|
|
$this->steamId = $steamId; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function GetSteamLevel() |
|
19
|
|
|
{ |
|
20
|
|
|
// Set up the api details |
|
21
|
|
|
$this->setApiDetails(__FUNCTION__, 'v0001'); |
|
22
|
|
|
|
|
23
|
|
|
// Set up the arguments |
|
24
|
|
|
$arguments = ['steamId' => $this->steamId]; |
|
25
|
|
|
|
|
26
|
|
|
// Get the client |
|
27
|
|
|
$client = $this->getServiceResponse($arguments); |
|
28
|
|
|
|
|
29
|
|
|
return $client->player_level; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function GetPlayerLevelDetails() |
|
33
|
|
|
{ |
|
34
|
|
|
$details = $this->GetBadges(); |
|
35
|
|
|
|
|
36
|
|
|
$details = new Level($details); |
|
37
|
|
|
|
|
38
|
|
|
return $details; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function GetBadges() |
|
42
|
|
|
{ |
|
43
|
|
|
// Set up the api details |
|
44
|
|
|
$this->setApiDetails(__FUNCTION__, 'v0001'); |
|
45
|
|
|
|
|
46
|
|
|
// Set up the arguments |
|
47
|
|
|
$arguments = ['steamId' => $this->steamId]; |
|
48
|
|
|
|
|
49
|
|
|
// Get the client |
|
50
|
|
|
$client = $this->getServiceResponse($arguments); |
|
51
|
|
|
|
|
52
|
|
|
return $client; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function GetCommunityBadgeProgress($badgeId = null) |
|
56
|
|
|
{ |
|
57
|
|
|
// Set up the api details |
|
58
|
|
|
$this->setApiDetails(__FUNCTION__, 'v0001'); |
|
59
|
|
|
|
|
60
|
|
|
// Set up the arguments |
|
61
|
|
|
$arguments = ['steamId' => $this->steamId]; |
|
62
|
|
|
if ($badgeId != null) { |
|
63
|
|
|
$arguments['badgeid'] = $badgeId; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
// Get the client |
|
67
|
|
|
$client = $this->getServiceResponse($arguments); |
|
68
|
|
|
|
|
69
|
|
|
return $client; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function GetOwnedGames($includeAppInfo = true, $includePlayedFreeGames = false, $appIdsFilter = []) |
|
73
|
|
|
{ |
|
74
|
|
|
// Set up the api details |
|
75
|
|
|
$this->setApiDetails(__FUNCTION__, 'v0001'); |
|
76
|
|
|
|
|
77
|
|
|
// Set up the arguments |
|
78
|
|
|
$arguments = ['steamId' => $this->steamId]; |
|
79
|
|
|
if ($includeAppInfo) { |
|
80
|
|
|
$arguments['include_appinfo'] = $includeAppInfo; |
|
81
|
|
|
} |
|
82
|
|
|
if ($includePlayedFreeGames) { |
|
83
|
|
|
$arguments['include_played_free_games'] = $includePlayedFreeGames; |
|
84
|
|
|
} |
|
85
|
|
|
if (count($appIdsFilter) > 0) { |
|
86
|
|
|
$arguments['appids_filter'] = (array) $appIdsFilter; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
// Get the client |
|
90
|
|
|
$client = $this->getServiceResponse($arguments); |
|
91
|
|
|
|
|
92
|
|
|
// Clean up the games |
|
93
|
|
|
$games = $this->convertToObjects(isset($client->games) ? $client->games : array()); |
|
94
|
|
|
|
|
95
|
|
|
return $games; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function GetRecentlyPlayedGames($count = null) |
|
99
|
|
|
{ |
|
100
|
|
|
// Set up the api details |
|
101
|
|
|
$this->setApiDetails(__FUNCTION__, 'v0001'); |
|
102
|
|
|
|
|
103
|
|
|
// Set up the arguments |
|
104
|
|
|
$arguments = ['steamId' => $this->steamId]; |
|
105
|
|
|
if (! is_null($count)) { |
|
106
|
|
|
$arguments['count'] = $count; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
// Get the client |
|
110
|
|
|
$client = $this->getServiceResponse($arguments); |
|
111
|
|
|
|
|
112
|
|
|
if ($client->total_count > 0) { |
|
113
|
|
|
// Clean up the games |
|
114
|
|
|
$games = $this->convertToObjects($client->games); |
|
115
|
|
|
|
|
116
|
|
|
return $games; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
return null; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function IsPlayingSharedGame($appIdPlaying) |
|
123
|
|
|
{ |
|
124
|
|
|
// Set up the api details |
|
125
|
|
|
$this->setApiDetails(__FUNCTION__, 'v0001'); |
|
126
|
|
|
|
|
127
|
|
|
// Set up the arguments |
|
128
|
|
|
$arguments = [ |
|
129
|
|
|
'steamId' => $this->steamId, |
|
130
|
|
|
'appid_playing' => $appIdPlaying |
|
131
|
|
|
]; |
|
132
|
|
|
|
|
133
|
|
|
// Get the client |
|
134
|
|
|
$client = $this->getServiceResponse($arguments); |
|
135
|
|
|
|
|
136
|
|
|
return $client->lender_steamid; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
protected function convertToObjects($games) |
|
140
|
|
|
{ |
|
141
|
|
|
$convertedGames = $this->convertGames($games); |
|
142
|
|
|
|
|
143
|
|
|
$games = $this->sortObjects($convertedGames); |
|
144
|
|
|
|
|
145
|
|
|
return $games; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
private function convertGames($games) |
|
149
|
|
|
{ |
|
150
|
|
|
$convertedGames = new Collection; |
|
151
|
|
|
|
|
152
|
|
|
foreach ($games as $game) { |
|
153
|
|
|
$convertedGames->add(new Game($game)); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
return $convertedGames; |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
|