Cruzyo.7304:

my guess by looking at it.
They read the information from the API every 15 minutes and save it into a database.

the API is basically a live-feed. If you want to review stuff from an earlier point, you need to set that up yourself and

so what do you need:
a database where you can save the information, the more details you want the larger the database will be.

Looking at them again, i’d assume a structure like this:
id (because you always use a id)
timestamp
green_score
blue_score
red_score
gw_camps (gw=green world)
gw_towers
gw_keeps
bw_camps (bw=blue world)
bw_towers
bw_keeps
rw_camps (rw=red world)
rw_towers
rw_keeps
eb_camps (eb=eternal battlegrounds)
eb_towers
eb_keeps
eb_sm

this would be all you need to store in a database to display it there.

next step would be the analysis of the API with a script, but at this point my knowledge ends, im not a coder, I can do database level stuff but not alot more than that, sadly ^^

but what would this script need to do?

First off, read the API the way you want, the first step would be letting the script figure out what color you are (unless you want to change the script every week) and what tier you’re in

so basically put a request to the https://api.guildwars2.com/v1/wvw/matches.json and let it return you the match_id and the color of your server_id.

This way you gain access to the https://forum-en.guildwars2.com/external?l=https%3A%2F%2Fapi.guildwars2.com%2Fv1%2Fwvw%2Fmatch_details.json

the match_id will tell you what match you’re going to look at, the color will tell you what you need to sum it.

but as i said, for more advanced techniques i cannot help, i only know this stuff in theory :P

second step would be to take the sums of the variables and store them into the database. that can be done with php indeed.

Foghladha.2506:

Yes. I first pull the world list and build an array of $world which will act as a World ID to Name Converter

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.guildwars2.com/v1/world_names.json”);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlRes = curl_exec($ch);
curl_close($ch);
$w = json_decode($curlRes, true);
$world = array();
foreach ($w as &$v) {
$wid = $v[‘id’];
$world[$wid] = $v[‘name’];
}
unset($v);

I then find the Match that my server (1013) is in.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.guildwars2.com/v1/wvw/matches.json”);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlRes = curl_exec($ch);
curl_close($ch);
$wld = json_decode($curlRes, true);
foreach ($wld[‘wvw_matches’] as &$v) {
if($v[‘red_world_id’] == ‘1013’ || $v[‘blue_world_id’] == ‘1013’ || $v[‘green_world_id’] == ‘1013’) {
$sormatch = $v[‘wvw_match_id’];
$r[‘id’] = $v[‘red_world_id’];
$b[‘id’] = $v[‘blue_world_id’];
$g[‘id’] = $v[‘green_world_id’];
}
}
unset($v);

Then I build the Objective Array

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.guildwars2.com/v1/wvw/objective_names.json”);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlRes = curl_exec($ch);
curl_close($ch);
$obj = json_decode($curlRes, true);
$objective = array();
foreach ($obj as &$v) {
$objid = $v[‘id’];
$objective[$objid] = $v[‘name’];
}
unset($v);

Foghladha.2506:

Lastly you need to build the data to import into your table.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.guildwars2.com/v1/wvw/match_details.json?match_id=”.$sormatch);
curl_setopt($ch, CURLOPT_HEADER, 0);
$curlRes = curl_exec($ch);
curl_close($ch);
$data = json_decode($curlRes, true);
$r[‘score’] = $data[‘scores’]0;
$r[‘name’] = $world[$r[‘id’]];
$b[‘score’] = $data[‘scores’]1;
$b[‘name’] = $world[$b[‘id’]];
$g[‘score’] = $data[‘scores’]2;
$g[‘name’] = $world[$g[‘id’]];
$side[‘Red’] = $r[‘name’];
$side[‘Blue’] = $b[‘name’];
$side[‘Green’] = $g[‘name’];
$pts[‘Camp’] = “5”;
$pts[‘Keep’] = “25”;
$pts[‘Tower’] = “10”;
$pts[‘Castle’] = “35”;
/*
CALCULATE POINT TOTALS
*/
$battle = $data[‘maps’];
$warzones[‘Center’] = “Eternal Battleground”; $warzonescode[‘Center’] = “eb”;
$warzones[‘BlueHome’] = “Blue Borderlands”; $warzonescode[‘BlueHome’] = “bb”;
$warzones[‘RedHome’] = “Red Borderlands”; $warzonescode[‘RedHome’] = “rb”;
$warzones[‘GreenHome’] = “Green Borderlands”; $warzonescode[‘GreenHome’] = “gb”;
$r[‘tick’] = 0;
$b[‘tick’] = 0;
$g[‘tick’] = 0;
// PRESET TOTALS
$totals[‘eb’][‘sc’] = 0;
$totals[‘eb’][‘tower’] = 0;
$totals[‘eb’][‘keep’] = 0;
$totals[‘eb’][‘castle’] = 0;
$totals[‘bb’][‘sc’] = 0;
$totals[‘bb’][‘tower’] = 0;
$totals[‘bb’][‘keep’] = 0;
$totals[‘bb’][‘castle’] = 0;
$totals[‘gb’][‘sc’] = 0;
$totals[‘gb’][‘tower’] = 0;
$totals[‘gb’][‘keep’] = 0;
$totals[‘gb’][‘castle’] = 0;
$totals[‘rb’][‘sc’] = 0;
$totals[‘rb’][‘tower’] = 0;
$totals[‘rb’][‘keep’] = 0;
$totals[‘rb’][‘castle’] = 0;

foreach ($battle as &$v) {
$bg[‘name’] = $warzones[$v[‘type’]];
$bg[‘code’] = $warzonescode[$v[‘type’]];
foreach ($v[‘objectives’] as &$o) {
$id = $o[‘id’];
$type = $objective[$id];
$faction = $side[$o[‘owner’]];
if(isset($o[‘owner_guild’])) {
$claimed = 1;
$text = " and is claimed";
$guild = $o[‘owner_guild’];
} else {
$claimed = 0;
$text = "";
}
if($type == “Keep”) {
$ptsaward = 25;
$objtype = “keep”;
} elseif($type == “Tower”) {
$ptsaward = 10;
$objtype = “tower”;

} elseif($type == “Castle”) {
$ptsaward = 35;
$objtype = “castle”;
} else {
$ptsaward = 5;
$objtype = “sc”;
}
if($faction == “Sanctum of Rall”) {
$totals[$bg[‘code’]][$objtype] = $totals[$bg[‘code’]][$objtype]+1;
}
if($o[‘owner’] == “Red”) { $r[‘tick’] = $r[‘tick’] + $ptsaward; }
if($o[‘owner’] == “Green”) { $g[‘tick’] = $g[‘tick’] + $ptsaward; }
if($o[‘owner’] == “Blue”) { $b[‘tick’] = $b[‘tick’] + $ptsaward; }
}
}
$gb_sc = $totals[‘gb’][‘sc’];
$gb_towers = $totals[‘gb’][‘tower’];
$gb_keeps = $totals[‘gb’][‘keep’];
$gb_pts = ($gb_sc*5) + ($gb_towers*10) + ($gb_keeps*25);

$bb_sc = $totals[‘bb’][‘sc’];
$bb_towers = $totals[‘bb’][‘tower’];
$bb_keeps = $totals[‘bb’][‘keep’];
$bb_pts = ($bb_sc*5) + ($bb_towers*10) + ($bb_keeps*25);

$rb_sc = $totals[‘rb’][‘sc’];
$rb_towers = $totals[‘rb’][‘tower’];
$rb_keeps = $totals[‘rb’][‘keep’];
$rb_pts = ($rb_sc*5) + ($rb_towers*10) + ($rb_keeps*25);

$eb_sc = $totals[‘eb’][‘sc’];
$eb_towers = $totals[‘eb’][‘tower’];
$eb_keeps = $totals[‘eb’][‘keep’];
$eb_castles = $totals[‘eb’][‘castle’];
$eb_pts = ($eb_sc*5) + ($eb_towers*10) + ($eb_keeps*25) + ($eb_castles*35);

Then just take the values and do what you like with them. I insert them into a database. I also cron job the script to run every 15 minutes.