Yeah I want to have it up to date at least every 15 minutes, possibly more frequent if possible.
I was doing some research and came across something. It will goto Duncans site and save the XML File to a cache directory on my server.
The only thing is, it doesn't grab everything properly. If I can get this working I would like to see how quickly it could loop through my users and save XML files on my server.............and then figure out how to take those file in my cache folder and insert them into my database.
<?
$gamertag = "ManHands14";
$filename = "cache/$gamertag.xml";
$url = "http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag=$gamertag";
$age = 3600;
if (file_exists($filename) && ((time() - filemtime($filename)) < $age)) {
$usedfile = true;
echo 'From Local File' . '<br />';
} else {
$f_contents = file_get_contents($url);
$fp = fopen($filename, 'wb');
fwrite($fp, $f_contents);
fclose($fp);
$usedfile = false;
echo 'From Remote File' . '<br />';
}
//$xml = simplexml_load_file($filename);
//echo $xml->channel->title, '<br />';
//echo '<br />';
echo htmlspecialchars(file_get_contents($filename));
//foreach ($xml->channel->item as $item) {
// echo "<A HREF=\"$item->link\">$item->title</A>", '<br />';
//echo $item->description, '<br />';
//echo $item->pubDate, '<br />';
//echo '<br />';
//}
if (!$usedfile) {
echo $f_contents . '<br />';
echo 'File Saved' . '<br />';
}
?>
Keep in mind I don't have PHP5 yet so I cannot use simplexml, so I commented those portions out. If you run the script on your server you will notice that it does save an xml file to the cache directory. But some of the xml is missing or the format is not correct/parsing.