Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.x dev #8

Merged
merged 3 commits into from
Jul 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions source/2.0/includes/classes/api.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function fetch_achievements($gamertag, $gameid, $region) {
$achievements['achievement']['current'] = $json['Game']['Progress'][$g]['Achievements'];
$achievements['achievement']['total'] = $json['Game']['PossibleAchievements'];
$achievements['progress'] = $json['Players'][0]['PercentComplete'];
$achievements['lastplayed'] = substr(str_replace(array("/Date(", ")/"), "", $json['Game']['Progress'][$g]['LastPlayed']), 0, 10);
$achievements['lastplayed'] = (int)substr(str_replace(array("/Date(", ")/"), "", $json['Game']['Progress'][$g]['LastPlayed']), 0, 10);

$i = 0;
foreach($json['Achievements'] as $achievement) {
Expand Down Expand Up @@ -243,7 +243,7 @@ public function fetch_games($gamertag, $region) {
$games['games'][$i]['achievements']['current'] = $game['Progress'][$g]['Achievements'];
$games['games'][$i]['achievements']['total'] = $game['PossibleAchievements'];
$games['games'][$i]['progress'] = 0;
$games['games'][$i]['lastplayed'] = substr(str_replace(array("/Date(", ")/"), "", $game['Progress'][$g]['LastPlayed']), 0, 10);
$games['games'][$i]['lastplayed'] = (int)substr(str_replace(array("/Date(", ")/"), "", $game['Progress'][$g]['LastPlayed']), 0, 10);

$games['gamerscore']['total'] = $games['gamerscore']['total'] + $games['games'][$i]['gamerscore']['total'];
$games['achievements']['current'] = $games['achievements']['current'] + $games['games'][$i]['achievements']['current'];
Expand All @@ -260,7 +260,7 @@ public function fetch_games($gamertag, $region) {
$games['freshness'] = $freshness;

return $games;
} else if($json['Data']['Players'][0]['Gamertag'] == "xboxleaders com") {
} else if($json['Data']['Players'][0]['Gamertag'] == "ACCOUNT_GAMERTAG") { //!!! Change this to the scraper account's gamertag
$this->error = 501;
return false;
} else {
Expand Down Expand Up @@ -313,7 +313,7 @@ public function fetch_friends($gamertag, $region) {
$friends['friends'][$i]['gamerscore'] = $friend['GamerScore'];
$friends['friends'][$i]['online'] = $friend['IsOnline'] == 1 ? true : false;
$friends['friends'][$i]['status'] = $friend['Presence'];
$friends['friends'][$i]['lastseen'] = substr(str_replace(array("/Date(", ")/"), "", $friend['LastSeen']), 0, 10);
$friends['friends'][$i]['lastseen'] = (int)substr(str_replace(array("/Date(", ")/"), "", $friend['LastSeen']), 0, 10);

$friends['total'] = ++$friends['total'];
if($friend['IsOnline']) {
Expand Down
5 changes: 5 additions & 0 deletions source/includes/classes/base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public function output_payload($data) {
}

public function output_error($code) {
// output the response code
if(array_key_exists((int)$code, $this->errors)) {
http_response_code((int)$code);
}

if($this->version == "1.0") {
$payload = array(
"Error" => $this->errors[$code],
Expand Down