Skip to content

Instantly share code, notes, and snippets.

@phatduckk
Created March 27, 2014 19:19
Show Gist options
  • Save phatduckk/9815891 to your computer and use it in GitHub Desktop.
Save phatduckk/9815891 to your computer and use it in GitHub Desktop.
<?php
$base = "https://www.lootsy.com/api/1.2/catalog?tag=%24f&beforeId=";
$ids = [];
$items = [];
do {
$beforeId = empty($ids) ? "" : end($ids);
$url = $base . $beforeId;
echo "$url\n";
$json = file_get_contents($url);
$o = json_decode($json);
if (empty($o->body)) {
break;
}
foreach ($o->body as $item) {
if (in_array($item->id, $ids)) {
echo "already have " . $item->id . "\n";
exit();
}
$ids[] = $item->id;
}
} while (true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment