Catch an XML error

Hello! I write code for a gaming site that uses a company called gameME to record stats for the players in the game. The company provides an api that uses an XML file for use in a php file to get stats, server info, etc. But the company limits api calls to 500 calls per thirty minutes. Our site has grown exponentially lately and this limit is being reached often. and when it does, the entire page becomes just a php error page with a list of errors consisting of failing to construct a new simple xml file on line 46 or whatever.

An example of a line of code that fails is
[php]$tfpxml = new SimpleXMLElement(file_get_contents(CLIENT_API_URL."/playerinfo/tf/".$steamid));[/php]

I put in a try/catch code to make the page viewable again:
[php]try {
$tfpxml = new SimpleXMLElement(file_get_contents(CLIENT_API_URL."/playerinfo/tf/".$steamid));
} catch (Exception $e) {
echo ‘GameME API Limit Reached’;

This still spits out a bunch of error messages at the top of the page (at least you can see the page now). But i’d like to make is so that none of those error messages get returned and it just says GameME API Limit Reached.

Sponsor our Newsletter | Privacy Policy | Terms of Service