/**
  * @return \model\Game || null
  * @throws TheGamesDBDownException
  */
 private function checkMultiplayerGame($game)
 {
     $name = $game['name'];
     $gameInfo = parent::makeGetRequest("http://thegamesdb.net/api/GetGame.php?exactname={$name}&platform=pc");
     if ($gameInfo === null) {
         throw new \TheGamesDBDownException();
     }
     if (@($gameXML = simplexml_load_string($gameInfo))) {
         $parsedGame = $gameXML->Game[0];
         if (isset($parsedGame->Players) && (string) $parsedGame->Players !== "1" && (string) $parsedGame->GameTitle === $name) {
             $title = (string) $parsedGame->GameTitle;
             $description = (string) $parsedGame->Overview;
             $developer = (string) $parsedGame->Developer;
             $id = (string) $parsedGame->id;
             $logoUrl = "{$game['appid']}/{$game['img_logo_url']}";
             $rating = (string) $parsedGame->Rating;
             // Genres are split in TheGamesDB, hence merging them
             $mergedGenre = "";
             $genres = $parsedGame->Genres->genre;
             for ($i = 0; $i < count($genres); $i++) {
                 $genre = (string) $genres[$i];
                 $mergedGenre .= $i === count($genres) - 1 ? "{$genre}" : "{$genre}, ";
                 // Fencepost error fix ^, the last subgenre would have a comma and
                 // space behind it without it
             }
             $game = new \model\Game($id, $title, $description, $logoUrl, $rating, $mergedGenre, $developer);
             if ($parsedGame->Images !== null) {
                 foreach ($parsedGame->Images->fanart as $art) {
                     $game->addArt((string) $art->original);
                 }
                 foreach ($parsedGame->Images->screenshot as $printscreen) {
                     $game->addArt((string) $printscreen->original);
                 }
             }
             return $game;
         }
     } else {
         return;
     }
 }
Пример #2
0
 public function __destruct()
 {
     parent::__destruct();
 }
Пример #3
0
 /**
  * @param string representing Steam ID of Steam user
  * @return array with one inner array per game
  * @throws PrivateProfileException if user with $id has their profile private
  */
 private function getOwnedGames($id)
 {
     $key = self::$APIkey;
     $url = "http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={$key}&steamid={$id}&format=json&include_appinfo='true'&include_played_free_games='true'";
     $gamesJson = parent::makeGetRequest($url);
     $gamesArray = json_decode($gamesJson, true);
     if (isset($gamesArray['response']['games'])) {
         return $gamesArray['response']['games'];
     } else {
         throw new \PrivateProfileException();
     }
 }