Skip to content

Instantly share code, notes, and snippets.

@majd
Last active December 28, 2016 18:34
Show Gist options
  • Save majd/9ea6089ccfa839ee44d9ed6a1458eacb to your computer and use it in GitHub Desktop.
Save majd/9ea6089ccfa839ee44d9ed6a1458eacb to your computer and use it in GitHub Desktop.
Check AirPods' stock in specified Apple Stores
<?php
/* HOW TO:
*
* 1. Get store name & identifier from http://www.istocknow.com/live
* 2. Update the stores array below
* 3. Run this and wait to get spammed with emails every minute
*
* Thanks to istocknow.com. Please don't spam it with tons of requests.
*/
$stores = ["255" => "Apple Store Syracuse"];
while (1) {
$time = date('d/m/Y H:i:s', time());
echo "\n[*] Checking at $time\n";
$response = json_decode(file_get_contents("http://www.istocknow.com/live/live.php?device.0=airpods"), true);
if (isset($response["dataz"])) {
$data = $response["dataz"];
foreach ($stores as $store_id => $store_name) {
if (array_key_exists($store_id, $data)) {
$store_json = $data[$store_id];
if (intval($store_json["live"]) == 1) {
echo "[Yes]";
mail("email@example.com", "Found AirPods", "Hi there, $store_name has AirPods in stock.");
} else {
echo "[No]";
}
echo " $store_name \n";
}
}
} else {
echo "[*] Invalid response\n";
}
sleep(300);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment