diff --git a/src/Syntax/SteamApi/Client.php b/src/Syntax/SteamApi/Client.php index e4bf249..7ec687e 100644 --- a/src/Syntax/SteamApi/Client.php +++ b/src/Syntax/SteamApi/Client.php @@ -135,26 +135,13 @@ protected function setUpXml(array $arguments = []) return simplexml_load_file($steamUrl . '?' . $parameters); } - public function getRedirectUrl() - { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $this->url); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - curl_exec($ch); - $this->url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); - curl_close($ch); - } - /** - * @param \GuzzleHttp\Psr7\Request $request + * @param \Guzzle\Http\Message\RequestInterface $request * - * @return \stdClass - * @throws \Syntax\SteamApi\Exceptions\ApiCallFailedException + * @throws ApiCallFailedException + * @return stdClass */ - protected function sendRequest(Request $request) + protected function sendRequest($request) { // Try to get the result. Handle the possible exceptions that can arise try { diff --git a/src/Syntax/SteamApi/Steam/User/Stats.php b/src/Syntax/SteamApi/Steam/User/Stats.php index 457d2e5..b8e2697 100644 --- a/src/Syntax/SteamApi/Steam/User/Stats.php +++ b/src/Syntax/SteamApi/Steam/User/Stats.php @@ -80,17 +80,15 @@ public function GetPlayerAchievements($appId) return $achievements; } catch (\Exception $e) { // In rare cases, games can force the use of a simplified name instead of an app ID - // In these cases, try again by grabbing the redirected url. + // In these cases, try again with the name. if (is_int($appId)) { - $this->getRedirectUrl(); + $app = $this->app()->appDetails($appId); - // Get the client - $client = $this->setUpXml($arguments); + if (isset($app->first()->name)) { + $appName = str_replace(' ', '', $app->first()->name); - // Clean up the games - $achievements = $this->convertToObjects($client->achievements->achievement); - - return $achievements; + return $this->GetPlayerAchievements($appName); + } } // If the name and ID fail, return null.