Jump to content

How to check if URL file is Json


Recommended Posts

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


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...