Posted May 20, 201510 yr Hi, I am using IPB 4, and I am making a request to the steam API to retrieve stats for a game.$playerData = \IPS\Http\Url::external("http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=221380&key=".$loginHandler->settings['st_api_key']."&steamid=".$this->member->st_id."&format=json")->request()->get()->decodeJson(); The only problem is that depending on the User it won't retrieve a valid Json file if there isn't any game data. How can I have this code catch an exception or check if it's a valid json file before decoding?
May 20, 201510 yr try{ $playerData = \IPS\Http\Url::external("http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=221380&key=".$loginHandler->settings['st_api_key']."&steamid=".$this->member->st_id."&format=json")->request()->get()->decodeJson(); } catch(\RuntimeException $e) { //handle it } Edited May 22, 201510 yr by Mark
Archived
This topic is now archived and is closed to further replies.