Skip to content

Instantly share code, notes, and snippets.

@Vusys
Last active December 31, 2016 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vusys/a8617f39b6460855f5af2431e494b705 to your computer and use it in GitHub Desktop.
Save Vusys/a8617f39b6460855f5af2431e494b705 to your computer and use it in GitHub Desktop.
<?php
$user = "xxxx";
$hash = "xxxx";
$url = "https://www.reddit.com/r/wow/api/flairlist.json";
$next = null;
$fp = fopen('./flair_list.csv', 'w');
$has_next = true;
$loop = 0;
while ($has_next == true) {
$loop++;
$query_args = [
'feed' => $hash,
'user' => $user,
'limit' => 1000,
];
if (!is_null($next)) {
$query_args['after'] = $next;
}
$query = $url . '?' . http_build_query($query_args);
$json = file_get_contents($query);
$json = json_decode($json, true);
$subreddit_users = $json['users'];
foreach ($subreddit_users as $subreddit_user) {
fputcsv($fp, $subreddit_user);
}
if (isset($json['next'])) {
$next = $json['next'];
} else {
print "done!" . "\n";
$has_next = false;
}
print "Downloaded {$loop} pages of users" . "\n";
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment