Skip to content

@maerlyn /README.md
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
script to get sum-by-type reputation changes on SO
<?php
$user_id = 308825;
$url_pattern = "https://api.stackexchange.com/2.1/users/%d/reputation-history?page=%s&pagesize=100&site=stackoverflow";
$page = 1;
$sum_by_type = array();
do {
echo "\rgetting page " . $page . "...";
$url = sprintf($url_pattern, $user_id, $page);
$contents = gzdecode(file_get_contents($url));
$page_contents = json_decode($contents, true);
foreach ($page_contents["items"] as $v) {
if (!isset($sum_by_type[$v["reputation_history_type"]])) {
$sum_by_type[$v["reputation_history_type"]] = 0;
}
$sum_by_type[$v["reputation_history_type"]] += $v["reputation_change"];
}
$has_more = $page_contents["has_more"];
++$page;
} while ($has_more);
echo "\n\n";
arsort($sum_by_type);
foreach ($sum_by_type as $k => $v) {
echo $k . "\t" . $v . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.