io ho trovato questo già bello pronto non è che ne capisco molto ma cmq se lo provi ti accorgerai che non aggiorna i dati perchè la chache non viene eliminata, come posso fare a far in modo che vengo aggiornato ongni tot minuti ?
Codice PHP:
<?php
/*
Usage: <?php echo xboxGamercard('GamerTag'); ?>
The gamercard info is cached as a text file for speed and server load purposes. By default,
the cache will not be older than 15 Minutes.
You will have to adjust the path to the images folder.
*/
function xboxGamercard($tag = 'JAY BUZ', $gamesAmount = 5)
{
$tag = urlencode($tag);
$abstand = time() - $file[0];
$timeout = 15; // minutes
if ($abstand > $timeout*60 || $tag != $file[1])
{
$data = file_get_contents('http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag='.$tag);
$xml = new SimpleXmlElement($data, LIBXML_NOCDATA);
$gamerTag = str_replace("+"," ", $tag);
$gamerMembership = $xml->AccountStatus;
$match = preg_match('#seen (.+?) (ago| playing)#', $xml->PresenceInfo->Info, $gameStatusTime);
$gameStatusTime = $match ? ', '.$gameStatusTime[1] : '';
$gamerStatus = $xml->PresenceInfo->Online == 'true' ? '<span id="online">Online</span>' : '<span id="offline">Offline</span>';
$gamerplayng = $xml->PresenceInfo->Info;
$gametitle = $xml->PresenceInfo->Title;
$gamerplaynggame = $xml->PresenceInfo->Info2;
$gamerTile = $xml->TileUrl;
$gamerRep = round(($xml->Reputation)/5);
$gamerScore = $xml->GamerScore;
$gamerZone = $xml->Zone;
$games = $xml->RecentGames->XboxUserGameInfo;
$i = 0;
foreach ($games as $game)
{
$image = $game->Game->Image32Url;
$name = $game->Game->Name;
$myScore = $game->GamerScore;
$totalScore = $game->Game->TotalGamerScore;
if ($i < $gamesAmount)
$gameList .= '[img]'.$image.'[/img]';
$i++;
}
$cacheString = time()."\n".
$tag."\n".
$gamerMembership."\n".
$gamerStatus."\n".
$gamerplayng."\n".
$gametitle."\n".
$gamerplaynggame."\n".
$gamerTile."\n".
$gamerRep."\n".
$gamerScore."\n".
$gamerZone."\n".
$gameList;
}
else
{
$tag = $file[1];
$gamerTag = str_replace('%20',' ', $tag);
$gamerMembership = $file[2];
$gamerStatus = $file[3];
$gamerplayng = $file[4];
$gametitle = $file[5];
$gamerplaynggame = $file[6];
$gamerTile = $file[7];
$gamerRep = $file[8];
$gamerScore = $file[9];
$gamerZone = $file[10];
$gameList = $file[11];
}
$gamerRep = "../imgs/xboxRep/rep".$gamerRep.".png";
$output = '
<div class="gamerCard">
[img]'.$gamerTile.'[/img]
<h2>[url="http://profile.mygamercard.net/'.$tag.'"]'.$gamerTag.'[/url]</h2>
[size="1"]GamerScore: <span>'.$gamerScore.'
'.$gamerStatus.'
'.$gamerplayng.'
'.$gamerplaynggame.'</span>[/size]</p>
<div class="recentGames">'.$gameList.'</div>
</div>';
return $output;
}
?>
<?php echo xboxGamercard('Ar3s 87'); ?>