/ Published in: PHP
Expand |
Embed | Plain Text
<?php class gamerTag{ private $tag; private $xml; public function __construct( $tag = '' ){ if( $tag != '' ){ $this -> gamerTags[] = $this -> tag; $this -> loadXML(); } } private function loadXML(){ $xml = simplexml_load_file( 'http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=' . $this -> tag ); if( $xml ){ $this -> status[$this -> tag] = (string) $xml -> State; $this -> cardInfo[$this -> tag]['status'] = (string) $xml -> AccountStatus; $this -> cardInfo[$this -> tag]['score'] = (int) $xml -> GamerScore; $this -> cardInfo[$this -> tag]['country'] = (string) $xml -> Country; $this -> cardInfo[$this -> tag]['zone'] = (string) $xml -> Zone; $this -> cardInfo[$this -> tag]['reputation'] = (int) $xml -> Reputation; $this -> cardInfo[$this -> tag]['profile'] = (string) $xml -> ProfileUrl; $this -> cardInfo[$this -> tag]['tag'] = (string) $xml -> Gamertag; $this -> cardImgs[$this -> tag]['tile'] = (string) $xml -> TileUrl; $this -> cardImgs[$this -> tag]['reputation'] = (string) $xml -> ReputationImageUrl; $this ->cardOnOFF[$this -> tag]['valid'] = (bool) $xml -> PresenceInfo -> Valid; $this ->cardOnOFF[$this -> tag]['lastseen'] = (string) $xml -> PresenceInfo -> LastSeen; $this ->cardOnOFF[$this -> tag]['online'] = (bool) $xml -> PresenceInfo -> Online; $this ->cardOnOFF[$this -> tag]['statustext'] = (string) $xml -> PresenceInfo -> StatusText; $this ->cardOnOFF[$this -> tag]['title'] = (string) $xml -> PresenceInfo -> Title; $this ->cardOnOFF[$this -> tag]['info'] = (string) $xml -> PresenceInfo -> Info; foreach( $xml -> RecentGames -> XboxUserGameInfo as $game ){ $this -> games[$this -> tag][(string) $game -> Game -> Name]['totalachievements'] = (int) $game -> Game -> TotalAchievements; $this -> games[$this -> tag][(string) $game -> Game -> Name]['totalgamescore'] = (int) $game -> Game -> TotalGamerScore; $this -> games[$this -> tag][(string) $game -> Game -> Name]['image32url'] = (string) $game -> Game -> Image32Url; $this -> games[$this -> tag][(string) $game -> Game -> Name]['image64url'] = (string) $game -> Game -> Image64Url; $this -> games[$this -> tag][(string) $game -> Game -> Name]['lastplayed'] = (string) $game -> LastPlayed; $this -> games[$this -> tag][(string) $game -> Game -> Name]['achievements'] = (int) $game -> Achievements; $this -> games[$this -> tag][(string) $game -> Game -> Name]['score'] = (int) $game -> GamerScore; $this -> games[$this -> tag][(string) $game -> Game -> Name]['detailsurl'] = (string) $game -> DetailsURL; $this -> games[$this -> tag][(string) $game -> Game -> Name]['percentage'] = (int) ((int) $game -> GamerScore)? min(100, ((int) $game -> GamerScore / (int) $game -> Game -> TotalGamerScore) * 100) : 0; } } } public function addTag( $tag ){ $this -> gamerTags[] = $this -> tag; $this -> loadXML(); } } public function getStatus( $tag = '' ){ }else{ return( $this -> status[$this -> tag] ); } } public function getCardInfo( $tag = '' ){ }else{ return( $this -> cardInfo[$this -> tag] ); } } public function getImgsInfo( $tag = '' ){ }else{ return( $this -> cardImgs[$this -> tag] ); } } public function getOnlineInfo( $tag = '' ){ }else{ return( $this -> cardOnOFF[$this -> tag] ); } } public function getGamesInfo( $tag = '' ){ }else{ return( $this -> games[$this -> tag] ); } } } $card = new gamerTag( 'place_GamerTag' ); $tag = $card -> getStatus(); echo '<pre>'; echo '</pre>'; $tag = $card -> getCardInfo(); echo '<pre>'; echo '</pre>'; $tag = $card -> getOnlineInfo(); echo '<pre>'; echo '</pre>'; $tag = $card -> getImgsInfo(); echo '<pre>'; echo '</pre>'; $tag = $card -> getGamesInfo(); echo '<pre>'; echo '</pre>'; ?>
You need to login to post a comment.
