问题
I started messing around with the Steam API a bit ago, and I made a simple site showing profile information using the GetPlayerSummaries method. It's been working great, right until some of my friends started adding iOS emotes in their name, which causes the following:
Fatal error: Maximum execution time of 300 seconds exceeded in file on line 137
This is what's on that line in the file:
public function getPlayerSummary($steamid) {
$contents = file_get_contents( "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".SteamAPI_APIKey."&steamids=".$steamid );
$json = json_decode($contents, true);
foreach($json['response']['players'] as $key => $value) {
...
}
}
(This is in a function, $steamid is defined when calling the function)
This should return (JSON):
{
"response": {
"players": [
{
"steamid": "_removed_",
"communityvisibilitystate": 3,
"profilestate": 1,
"personaname": "_removed_ 👻",
"lastlogoff": 1426734965,
"profileurl": "http://steamcommunity.com/id/_removed_/",
"avatar": "_removed_",
"avatarmedium": "_removed_",
"avatarfull": "_removed_",
"personastate": 0,
"realname": "_removed_",
"primaryclanid": "_removed_",
"timecreated": 1349251405,
"personastateflags": 0,
"loccountrycode": "DE"
}
]
}
}
But the "👻" in the personaname messes it up, as it works for everyone else without it :/ This is a ghost emote, same happens with another friend using a monkey emote in his name.
Would anyone have any idea how I could resolve this?
回答1:
put following line at the top of php file,
ini_set("max_execution_time", 0);
回答2:
Note:
If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode().
http://php.net/manual/en/function.file-get-contents.php
来源:https://stackoverflow.com/questions/29139747/php-file-get-contents-maximum-execution-time-exceeded-cause-of-emotes