Skip to content

Commit

Permalink
Revert "Fixing an issue where some games would fail to find their ach…
Browse files Browse the repository at this point in the history
…ievements due to redirects. Fixes"

This reverts commit 1c0c1a0.
  • Loading branch information
stygiansabyss committed Feb 3, 2017
1 parent 1c0c1a0 commit 3b013bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
21 changes: 4 additions & 17 deletions src/Syntax/SteamApi/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 6 additions & 8 deletions src/Syntax/SteamApi/Steam/User/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3b013bf

Please sign in to comment.