Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4380898
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:35:07+00:00 2026-05-21T12:35:07+00:00

Well, I’m working with Bungie’s Halo Reach API. Right now my code will get

  • 0

Well, I’m working with Bungie’s Halo Reach API. Right now my code will get all the game ids for a particular player.

I want to store the game ids in a mysql database and then in the future if a player wants to update the database the script will only get the game ids that aren’t already in the database.

The script gets the most recent page $iPage = '0';
Then if HasMorePages is equal to true it gets the next page $iPage++ until HasMorePages is false.
Each page gives 25 game ids the last page may have less.

So basically I want to get game ids that weren’t there when the script was first run, without making unnecessary calls to the API. How could I do that?

<?php
include_once('sql.php'); // MySQL Connection
include_once('api.php'); // API unique identifer string

$gamertag = 'jam1efoster'; // Gamertag
$variant = 'Unknown'; // Unknown gets all game variants
$iPage = '0'; // 0 is the most recent page

while(!$endPages == true){

    $GetGameHistory = "http://www.bungie.net/api/reach/reachapijson.svc/player/gamehistory/".$apiKey."/".rawurlencode(strtolower($gamertag))."/".$variant."/".$iPage;

    $output = file_get_contents($GetGameHistory);
    $obj = json_decode($output);
    //echo $output;

    $mPages = $obj->HasMorePages;
    if($mPages == false){$endPages = true;}

    foreach($obj->RecentGames as $recentgames) {
        $gameId = $recentgames->GameId;
        //echo $gameId.'<br />';
    }
    //echo $iPage.'<br />';
    $iPage++;
}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:35:08+00:00Added an answer on May 21, 2026 at 12:35 pm

    Considering I understand what you’re trying to do and what you’re asking. Try this code:

    <?php
    include_once('sql.php'); // MySQL Connection
    include_once('api.php'); // API unique identifer string
    
    $gamertag = 'jam1efoster'; // Gamertag
    $variant = 'Unknown'; // Unknown gets all game variants
    $iPage = '0'; // 0 is the most recent page
    // get current ids
    $result=mysql_query('SELECT ALL CURRENT IDS');// PUT YOUR SQL HERE !
    $oldIds=array();
    $newIds=array();
    while($row=mysql_fetch_array($result))$oldIds[]=$row['id'];// might be different in your scenario
    // get all ids, unfortunately
    for(;;){
        $GetGameHistory = "http://www.bungie.net/api/reach/reachapijson.svc/player/gamehistory/".$apiKey."/".rawurlencode(strtolower($gamertag))."/".$variant."/".$iPage;
        $output = file_get_contents($GetGameHistory);
        $obj = json_decode($output);
        // get fresh ids
        foreach($obj->RecentGames as $recentgames) {
            if(in_array($recentgames->GameId, $oldIds))continue;// we already have this id
            $newIds[]=$recentgames->GameId;
        }
    
        if(!$obj->HasMorePages)break;// no more pages? break!
        $iPage++;
    }
    
    var_dump($newIds);
    ?>
    

    I’m unfamiliar with the method bungie might be pushing the games to the api. If they are ordered, comment. And I’ll revise my code. If they are arbitrary, kind of tough luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, I get this message all the time using AdWhirl: Unable to fill ad
Well... simple question, right? But with no so simple answers. In firefox i use
Well this interactive python console snippet will tell everything: >>> class Test: ... def
Well I made this game in java and when you shoot a bullet it
Well, i need to check if some fields are empty when submiting get an
Well, the subject says it all, basically. I have a command-line utility that may
Well, I've been programming for VB.NET for a while, and now I am interested
Well, I have website with such structure of pages: domain.com/group-1/page/ and now I need
Well the subject is the question basically. Are there any version control systems out
Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.