Closed Kovah closed 7 years ago
I honestly thought the appDetails method would always work here since that's all the method does is find app names. The fact that it has found an incorrect one is odd. Does get schema for game return the proper name?
I can't test the function properly at the moment because the name looks always like this: ValveTestApp224540
This problem seem to be not that rare: from more than 600 games about 80 returned no achievements because of this problem. It seems many games have a store title that differs from the actual internal game name. :/
If achievements use the store title it may be time I brought in the storefront API.
Could you try the GetSchemaForGame()
function? It still returns ValveTestApp224540
and I'm not sure if this is a local problem or a broken Steam API.. ?!
Just tested it again. GetSchemaForGame()
still returns ValveTestApp224540
as the name instead of the actual game.
I did something a little hackish and inside the GetPlayerAchievements()
method I did a curl request before try { $client = ...
and set $this->url
to the redirect url from the curl request. I don't know if it's perfect and I haven't really tested it but it resolved appId 220 (Half-Life 2) which it's achievements appname is HL2.
If you want to give it a try and test it more insert this code just before the try { ... } catch { ... }
block.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Must be set to true so that PHP follows any "Location:" header
url_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$this->url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
Also instead of trying to resolve the appName inside the catch block, I just returned null
.
@73cn0109y Your solution was fine. I cleaned up the implementation a little and pushed it out just now. I will be adding this to the next tagged release.
I just encountered some problems with the API with the following game:
Ace of Spaced
(App ID224540
)I tried to get all achievements for a profile by using the
GetPlayerAchievements()
function but it returnednull
. I double checked the Steam ID of the user and the App ID. Both are correct so I opened the URL the function tries to open in the browser and it returns the HTML page instead of the XML version.Okay, must be the rare case where the game name is required to return the XML data. But why does the function keeps returning
null
then?While trying to get the achievements, the function tries to get the game name by running
$app = $this->app()->appDetails($appId);
. However, this function is returning a completely wrong game name. Instead ofAceofSpades
it returnsAceofSpades:BattleBuilder
while the App ID stays the same.The problem
appDetails($appId)
tries to get information about the game from the games store page. However, the store page may display a different game name than reported byGetOwnedGames()
.Possible solution I think that a wrong API call is triggered here. Instead of using the Store API I would rather use the
GetSchemaForGame()
function, which may return the correct game name.