Created
March 27, 2014 19:19
-
-
Save phatduckk/9815891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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