Created
March 23, 2012 15:01
-
-
Save djekl/2171482 to your computer and use it in GitHub Desktop.
Plain version of XBOX Last Seen Widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = 'rentedsmile'; | |
$url = 'http://gamercard.xbox.com/en-US/' . rawurlencode($user) . '.card'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 5); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
$html = new DOMDocument; | |
$html->loadHTML($output); | |
$list = $html->getElementById('PlayedGames'); | |
$imge = $list->getElementsByTagName('img')->item(0)->getAttribute('src'); | |
$name = $list->getElementsByTagName('span')->item(0)->nodeValue; | |
$date = strtotime($list->getElementsByTagName('span')->item(1)->nodeValue); | |
$time = (date('dmy',$date)==date('dmy')) ? 'earlier today' : ((date('dmy',$date)==date('dmy',strtotime('yesterday'))) ? 'yesterday' : floor((time()-$date)/86400) . ' days ago'); | |
echo '<img src="' . $imge . '" /><a href="http://live.xbox.com/en-US/MyXbox/Profile?Gamertag=' . $user . '">' . $user . '</a> - Last seen ' . $time . ' playing ' . $name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment