Bungienetplatform Wiki
Advertisement

While the GetAdvisorsForCurrentCharacter endpoint requires the user to be logged in, it is possible to get most of the information it provides (and more) using the public GetActivityHistory endpoint.

There are however limitations:

  • GetActivityHistory lacks filter options and requires either multiple requests or one big request (which is how it is done below)
  • ArenaChallenge information is not currently available in the GetPublicAdvisors endpoint and has to be many changed each reset
  • GetActivityHistory only provides one date value so there will be errors with activities completed near the start and end of the daily/weekly period.
  • Characters have to be queried separately
  • The raid "bosses looted" information is only available in the private endpoint

PHP Script[]

<?php
// GetAccount: This should be cached at least every minute.
$account = the_account();

// GetPublicAdvisors: I'd recommend caching this since it will only change once per day
$advisors = get_json(BUNGIE_URL.'/Platform/Destiny/Advisors/');

$default_checklist = array(
    // Raids have to be manually set, but thankfully they don't change and there aren't many at the moment (hopefully not for too long though)
    'raidActivities' => array(
        'name' => 'Raid',
        'reset' => $advisors->data->nightfallResetDate,
        'activities' => array(
            array(
                'activityHash' => 2659248071,
                'tiers' => array(2659248071, 2659248068)
            ),
            array(
                'activityHash' => 1836893116,
                'tiers' => array(1836893116, 1836893119)
            )
        )
    ),
    'nightfall' => array(
        'name' => 'Nightfall',
        'reset' => $advisors->data->nightfallResetDate,
        'activities' => array(
            array(
                'activityHash' => $advisors->data->nightfallActivityHash,
                'tiers' => array($advisors->data->nightfallActivityHash)
            )
        )
    ),
    'heroicStrike' => array(
        'name' => 'Heroic Strike',
        'reset' => $advisors->data->heroicStrikeResetDate,
        'activities' => array(
            array(
                'activityHash' => $advisors->data->heroicStrikeHashes[0],
                'tiers' => $advisors->data->heroicStrikeHashes
            )
        )
    ),
    'dailyChapterActivities' => array(
        'name' => 'Daily Chapter',
        'reset' => $advisors->data->dailyChapterResetDate,
        'daily' => true,
        'activities' => array(
            array(
                'activityHash' => $advisors->data->dailyChapterHashes[0],
                'tiers' => $advisors->data->dailyChapterHashes
            )
        )
    ),
    'dailyCrucible' => array(
        'name' => 'Daily Crucible',
        'reset' => $advisors->data->dailyCrucibleResetDate,
        'daily' => true,
        'activities' => array(
            array(
                'activityHash' => $advisors->data->dailyCrucibleHash,
                'tiers' => array($advisors->data->dailyCrucibleHash)
            )
        )
    ),
    // Manually set until ArenaChallenges get added to GetPublicAdvisors
    'arenas' => array(
        'name' => 'Arena',
        'reset' => $advisors->data->nightfallResetDate,
        'activities' => array(
            array(
                'activityHash' => 2074618695,
                'tiers' => array(2074618695)
            ),
            array(
                'activityHash' => 1208087919,
                'tiers' => array(1208087919)
            ),
            array(
                'activityHash' => 2326253031,
                'tiers' => array(2326253031)
            )
        )
    )
);

$response = array('characters' => array());

// Iterate through account characters
foreach($account->data->characters as $char) {
    // GetActivityHistory: Grab the last 100 activities across all modes, once/if there's more filter options, this could probably done better...
    $recentActivities = get_json(BUNGIE_URL.'/Platform/Destiny/Stats/ActivityHistory/'.$account->data->membershipType.'/'.$account->data->membershipId.'/'.$char->characterBase->characterId.'/?mode=0&page=0&count=100');

    // Set up structure for current character checklist
    $checklist = $default_checklist;

    // Iterate through checklist types (ie raid, nightfall, etc)
    foreach($checklist as $type => $list) {
        // Setup the date range to filter activities
        $end = strtotime($list['reset']);
        $start = strtotime(date('Y-m-d h:i:s', $end).' -'.(isset($list['daily']) ? '1 day' : '7 days'));

        foreach($list['activities'] as $activity_index => $activity) {

            // Setup stats information defaults
            $activity['stats'] = array();
            foreach($activity['tiers'] as $tierHash) {
                $activity['stats'][$tierHash] = array(
                    'attempts' => array(),
                    'completions' => array(),
                    'isCompleted' => false
                );
            }

            // Iterate through recentActivities and find matches
            foreach($recentActivities->data->activities as $index => $recentActivity) {
                $tier_index = array_search($recentActivity->activityDetails->referenceId, $activity['tiers']);

                // Check that the activityHash matches and then that it started within the date range
                // This isn't going to catch activities that are completed after the end date though...
                if ($tier_index !== false && strtotime($recentActivity->period) >= $start) {
                    // Capture how many attempts were taken to beat it
                    $activity['stats'][$recentActivity->activityDetails->referenceId]['attempts'][] = $recentActivity->activityDetails->instanceId;

                    // Check if the activity was completed successfully
                    if ($recentActivity->values->completed->basic->value == 1) {
                        // Since completing an activity on a higher tier completes it also on lower tiers we have to track this
                        $activity['stats'][$recentActivity->activityDetails->referenceId]['completions'][] = $recentActivity->activityDetails->instanceId;
                        for ($i=0; $i<=$tier_index; $i++) {
                            $tierHash = $activity['tiers'][$i];
                            $activity['stats'][$tierHash]['isCompleted'] = true;
                        }
                    }
                }
            }
            $checklist[$type]['activities'][$activity_index] = $activity;
        }
    }

    $response['characters'][] = array(
        'characterId' => $char->characterBase->characterId,
        //'character' => $char, // Include the character information in the output
        'checklist' => $checklist
    );
}

header('Content-Type: application/json');
echo json_encode($account_checklist, JSON_PRETTY_PRINT);
exit();

Response[]

{
"characters": [
    {
        "characterId": "2305843009214854213",
        "checklist": {
            "raidActivities": {
                "name": "Raid",
                "reset": "2015-06-09T09:00:00Z",
                "activities": [
                    {
                        "activityHash": 2659248071,
                        "tiers": [
                            2659248071,
                            2659248068
                        ],
                        "stats": {
                            "2659248071": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": false
                            },
                            "2659248068": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": false
                            }
                        }
                    },
                    {
                        "activityHash": 1836893116,
                        "tiers": [
                            1836893116,
                            1836893119
                        ],
                        "stats": {
                            "1836893116": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": false
                            },
                            "1836893119": {
                                "attempts": [
                                    "2709734154",
                                    "2705841096",
                                    "2705127200"
                                ],
                                "completions": [

                                ],
                                "isCompleted": false
                            }
                        }
                    }
                ]
            },
            "nightfall": {
                "name": "Nightfall",
                "reset": "2015-06-09T09:00:00Z",
                "activities": [
                    {
                        "activityHash": 1985034593,
                        "tiers": [
                            1985034593
                        ],
                        "stats": {
                            "1985034593": {
                                "attempts": [
                                    "2710075624",
                                    "2672921415",
                                    "2672882709"
                                ],
                                "completions": [
                                    "2710075624",
                                    "2672921415",
                                    "2672882709"
                                ],
                                "isCompleted": true
                            }
                        }
                    }
                ]
            },
            "heroicStrike": {
                "name": "Heroic Strike",
                "reset": "2015-06-09T09:00:00Z",
                "activities": [
                    {
                        "activityHash": 1398976307,
                        "tiers": [
                            1398976307,
                            1398976306,
                            1398976305
                        ],
                        "stats": {
                            "1398976307": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": true
                            },
                            "1398976306": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": true
                            },
                            "1398976305": {
                                "attempts": [
                                    "2691256482"
                                ],
                                "completions": [
                                    "2691256482"
                                ],
                                "isCompleted": true
                            }
                        }
                    }
                ]
            },
            "dailyChapterActivities": {
                "name": "Daily Chapter",
                "reset": "2015-06-09T09:00:00Z",
                "daily": true,
                "activities": [
                    {
                        "activityHash": 2447102707,
                        "tiers": [
                            2447102707,
                            2447102704,
                            2447102705
                        ],
                        "stats": {
                            "2447102707": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": false
                            },
                            "2447102704": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": false
                            },
                            "2447102705": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": false
                            }
                        }
                    }
                ]
            },
            "dailyCrucible": {
                "name": "Daily Crucible",
                "reset": "2015-06-09T09:00:00Z",
                "daily": true,
                "activities": [
                    {
                        "activityHash": 2593008450,
                        "tiers": [
                            2593008450
                        ],
                        "stats": {
                            "2593008450": {
                                "attempts": [

                                ],
                                "completions": [

                                ],
                                "isCompleted": false
                            }
                        }
                    }
                ]
            },
            "arenas": {
                "name": "Arena",
                "reset": "2015-06-09T09:00:00Z",
                "activities": [
                    {
                        "activityHash": 2074618695,
                        "tiers": [
                            2074618695
                        ],
                        "stats": {
                            "2074618695": {
                                "attempts": [
                                    "2725158719",
                                    "2706426338",
                                    "2674324136"
                                ],
                                "completions": [
                                    "2725158719",
                                    "2706426338",
                                    "2674324136"
                                ],
                                "isCompleted": true
                            }
                        }
                    },
                    {
                        "activityHash": 1208087919,
                        "tiers": [
                            1208087919
                        ],
                        "stats": {
                            "1208087919": {
                                "attempts": [
                                    "2706661744",
                                    "2674521534"
                                ],
                                "completions": [
                                    "2706661744"
                                ],
                                "isCompleted": true
                            }
                        }
                    },
                    {
                        "activityHash": 2326253031,
                        "tiers": [
                            2326253031
                        ],
                        "stats": {
                            "2326253031": {
                                "attempts": [
                                    "2708725778"
                                ],
                                "completions": [
                                    "2708725778"
                                ],
                                "isCompleted": true
                            }
                        }
                    }
                ]
            }
        }
    }
]
}
Advertisement