Bungie의 Halo Reach API를 사용하고 있습니다. 지금 내 코드는 특정 플레이어에 대한 모든 게임 ID를 가져옵니다.게임 기록 데이터베이스를 업데이트하는 방법은 무엇입니까? Bungie Halo Reach API
게임 ID를 mysql 데이터베이스에 저장하고 싶습니다. 나중에 플레이어가 데이터베이스를 업데이트하고 싶다면 스크립트는 데이터베이스에 아직없는 게임 ID 만 가져옵니다. HasMorePages
그것이 HasMorePages
이 거짓이 될 때까지 다음 페이지 $iPage++
를 얻을 사실에 동일한 경우는
그런 다음 스크립트는 가장 최근의 페이지 $iPage = '0';
을 가져옵니다. 각 페이지에는 마지막 페이지의 게임 ID가 25 개 있습니다.
그래서 기본적으로 스크립트를 처음 실행할 때 없었던 게임 ID를 API에 불필요하게 호출하지 않고 싶습니다. 내가 어떻게 할 수 있니?
<?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++;
}
?>