Essential+ Posted May 20, 2015 Share Posted May 20, 2015 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? Link to comment Share on other sites More sharing options...
Marcher Technologies Posted May 20, 2015 Share Posted May 20, 2015 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 } Link to comment Share on other sites More sharing options...
LZDigital Posted May 20, 2015 Share Posted May 20, 2015 Thank you very much. New account but same person. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.