Skip to content

Commit

Permalink
Merge pull request #40 from XboxLeaders/develop
Browse files Browse the repository at this point in the history
Some bugfixes and optimizations
  • Loading branch information
Jason Clemons committed Sep 13, 2013
2 parents 1bfb37c + 896274a commit 6e49455
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions api/2.0/includes/classes/api.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@ public function fetch_profile($gamertag, $region)
$user['gamerscore'] = (int) trim($this->find($data, '<div class="gamerscore">', '</div>'));
$user['reputation'] = 0;
$user['presence'] = trim(str_replace("\r\n", ' - ', $this->find($data, '<div class="presence">', '</div>')));
$user['online'] = ((strpos($user['presence'], 'Last seen') !== false) or (strpos($user['presence'], 'Offline') !== false) or (strpos($user['presence'], ' ') !== false)) ? false : true;
$user['online'] = (bool)(strpos($user['presence'], 'Online') !== false);
$user['gamertag'] = str_replace(array('&#39;s Profile', '\'s Profile'), '', trim($this->find($data, '<h1 class="pageTitle">', '</h1>')));
$user['motto'] = $this->clean(trim(strip_tags($this->find($data, '<div class="motto">', '</div>'))));
$user['name'] = trim(strip_tags($this->find($data, '<div class="name" title="', '">')));
$user['location'] = trim(strip_tags(str_replace('<label>Location:</label>', '', trim($this->find($data, '<div class="location">', '</div>')))));
$user['biography'] = trim(strip_tags(str_replace('<label>Bio:</label>', '', trim($this->find($data, '<div class="bio">', '</div>')))));

$recentactivity = $this->fetch_games($gamertag, $region);
$user['recentactivity'] = array_slice($recentactivity['games'], 0, 5);
$recentactivity = $this->fetch_games($gamertag, $region);
if (is_array($recentactivity)) {
$user['recentactivity'] = array_slice($recentactivity['games'], 0, 5, true);
} else {
$user['recentactivity'] = null;
}

if (strpos($data, '<div class="badges">') !== false) {
if (strpos($data, 'xbox360Badge') !== false) {
Expand Down Expand Up @@ -316,7 +320,7 @@ public function fetch_friends($gamertag, $region)

$json = json_decode($data, true);

if ($json['Data']['Friends'] != null) {
if (!empty($json['Data']) && $json['Data']['Friends'] != null) {
$friends = array();
$friends['total'] = 0;
$friends['totalonline'] = 0;
Expand Down

0 comments on commit 6e49455

Please sign in to comment.