Xbox.com just released the ability to
create
and view your Xbox 360 gamercard online. The gamercard shows a bunch of statistics
and information from your gameplay with an Xbox 360. They also let you
post
the gamercard on your weblog using an IFRAME.
I wanted to include the gamercard on my weblog, but can't stand IFRAMES so I created
this simple PHP function that takes the gamercard and formats it so that you can insert
it into your website anywhere you can add PHP code.
You can see the result of the function at the top left of this webpage.
The function is after the break
Here is the function:
function insertGamerCard()
{
$handle = fopen("http://gamercard.xbox.com/YOURGAMERTAG.card", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
$pattern = '/<[^<]*)*<\/body>/';
([^<]*
preg_match( $pattern, $contents, $matches );
$contents = $matches[0];
$contents = preg_replace( Array( "/<body>/", "/<\/body>/" ), Array("",""),
$contents );
$contents = preg_replace( "/\"\//", "\"http://gamercard.xbox.com/", $contents );
return "<div class=\"gamercard\">\n\t". $contents. "\n</div>\n";
}
You will also need to add the following CSS to your blog's .css file:
.XbcgcStats
{
width:124px;
float:left;
position: relative;
left: 80px;
top: -80px;
}
.XbcgcStats p
{
display:block;
font-size:10px;
margin:3px 0 3px 0;
padding:0px 5px 0px 5px;
border-bottom:1px solid #898989;
height:15px;
}
.XbcgcGamertile
{
border:1px solid #AEAEAE;
}
.XbcgcGames
{
height:40px;
line-height:0px;
font-size:10px;
margin:0 0 0 1px;
font-size:10px;
}
.XbcgcGames img
{
margin:2px 0 0 6px;
border:0px;
}
.XbcFLAL
{
}
.XbcFRAR
{
position: relative;
top: -12px;
float:right;
text-align:right;
}
.XbcgcInfo
{
margin:0;width:197px;
height:79px;
font-size:10px;
}
.XbcgcContainer div.Xbcgc, .XbcgcContainer h3, .XbcgcContainer .XbcgcInfo
{
}
.XbcgcContainer01 div.Xbcgc, .XbcgcContainer01 h3, .XbcgcContainer01 .XbcgcInfo
{
}
.gamercard{
padding-top: 0px;
margin: 0px;
height: 140px;
width: 198px;
background-position:0px -18px;
}
>
You will likely need to tweak the CSS to have it work well on your site.
If you have any problems installing this code, or if you make use of it. Pleae leave
a link in the commments. I'd love to see what is being done with it.