2015-03-19 50 views
0

我開始在Steam API的前面搞亂了,並且我使用GetPlayerSummaries方法創建了一個顯示配置文件信息的簡單站點。它一直致力於偉大的,正確的,直到我的一些朋友開始加入iOS的表情在他們的名字,這會導致如下:PHP file_get_contents超出最大執行時間(表情的原因?)

致命錯誤:超過300秒最長執行時間文件上線137

這是針對該文件在該行:

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) { 
     ... 
    } 
} 

(這是一個函數,$汽調用函數)

這應返回(JSON)當ID定義:

{ 
"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" 
     } 
    ] 

} 

}

但是 「」 在personaname打亂它,因爲它適用於所有的人,而不它:/這是一個幽靈表情,和另一個朋友在他的名字中使用猴子表情一樣。

有沒有人有任何想法我可以解決這個問題?

+0

請張貼更多的代碼,我不認爲'file_get_contents'導致這(PHP是不是報告錯誤非常好),我的猜測是'json_decode'不能分析奇怪的字符,你可以[在內容中不替換utf-8字符](http://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-字符串),然後是'json_decode'字符串 – 2015-03-19 08:30:10

+0

增加了一點點,雖然除了函數中的'file_get_contents'仍然導致它:/ – Mitch 2015-03-19 08:48:19

+0

如果您嘗試通過char讀取文件char,會發生什麼? http://pastebin.com/Qr7RxvHW – 2015-03-19 09:06:58

回答

0

放下面的PHP文件的第一行,

ini_set("max_execution_time", 0); 
+0

我不知道這將如何幫助我的情況?這會導致頁面永不加載,haha – Mitch 2015-03-19 08:23:43

+0

你可以在php.ini中做到這一點 – 2015-03-19 08:25:55

+0

是的,我知道,但那會如何幫助? :/我做到了,它永遠不會加載 – Mitch 2015-03-19 08:31:24