/** * Fetches the games this user owns * * @see getGames() * @throws SteamCondenserException if an error occurs while parsing the * data */ private function fetchGames() { $gamesData = $this->getData($this->getBaseUrl() . '/games?xml=1'); $this->games = []; $this->playtimes = []; foreach ($gamesData->games->game as $gameData) { $appId = (int) $gameData->appID; $game = SteamGame::create($appId, $gameData); $this->games[$appId] = $game; $recent = (double) $gameData->hoursLast2Weeks; $total = (double) str_replace(',', '', $gameData->hoursOnRecord); $playtimes = [(int) ($recent * 60), (int) ($total * 60)]; $this->playtimes[$appId] = $playtimes; } }
/** * Returns the base Steam Community URL for the stats contained in this * object * * @return string The base URL used for queries on these stats */ public function getBaseUrl() { return self::_getBaseUrl($this->user->getId(), $this->game->getId()); }
/** * Fetches the games this user owns * * @see getGames() * @throws SteamCondenserException if an error occurs while parsing the * data */ public function fetchGames() { $params = ['steamid' => $this->getSteamId64(), 'include_appinfo' => 1, 'include_played_free_games' => 1]; $gamesData = WebApi::getJSONObject('IPlayerService', 'GetOwnedGames', 1, $params); foreach ($gamesData->response->games as $gameData) { $game = SteamGame::create($gameData); $this->games[$game->getAppId()] = $game; if (property_exists($gameData, 'playtime_2weeks')) { $recent = $gameData->playtime_2weeks; } else { $recent = 0; } $total = $gameData->playtime_forever; $this->playtimes[$game->getAppId()] = [$recent, $total]; } return $this->games; }