tags:

views:

42

answers:

1

After hours and hours of searching I finally found an api script for gamercards. Only problem is this freaking thing updates every 30 mins. If I open a new browser and go to the url I get the most recent updated info. Is there a way to trick this thing to think each refresh is a new browser session?

http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=gamerholics

here's the script.

<?php
$ch = curl_init("http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=gamerholics");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);

$data = curl_exec($ch);
curl_close($ch);

$xml = new SimpleXmlElement($data, LIBXML_NOCDATA);

foreach ($xml->PresenceInfo as $mystatus) 
{
print  '<div id="xboxlivestatus"><a href="' . $xml->ProfileUrl . '">' . $xml->Gamertag . '</a> is ' . $mystatus->StatusText . ' : ' . $mystatus->Info . ' : ' . $mystatus->Info2. '</div>';
}

?>
A: 

If your curl is storing cookies somewhere, then most likely it's keeping a cookie around that's giving you the 30 minute timeout. Try using

curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);

to force session cookies (so they wipe after each run). As well, investigate if there's a cookie jar file somewhere, which you might have to wipe seperately to truly force a new session with the API each time.

Marc B
thanks for your response bro, I've pretty much given up on this and tried a new walk around that stores the data in a data base each time one of my members use the script, so this way I have the most recent data to show at all times.
John Sims