sharedRoutine iOS Developer     About     Contact     Projects

How I got my iPhone 7+ earlier

Here’s my story on how I tried to get an iPhone 7 Plus - and succeeded within 2 days instead of waiting 4-5 weeks on its delivery

As of today (October 17, 2016) the iPhone 7 Plus is not really widely available, in fact it took me 4-5 Weeks to get one ordering on October 11th. It told me that I had to wait till November 10th-17th to get my iPhone 7 Plus delivered. I did not want to wait so long, so I was looking for another option. A friend of mine recommended [istocknow]](http://www.istocknow.com/live/) to me and I immediately spent hours on hitting CMD + R to refresh the website to see if my Apple Store had one available.

I also sometimes woke up at odd hours to check the status, like 6am :P But I thought about making that checking automated and notify myself in case an iPhone in the configuration was available. So I used Charles Proxy Tool to check if the website might use an API that I also could access. What I found was this:

(I wanted an iPhone 7 Plus 128GB Black)

http://www.istocknow.com/live/live.php?type=7plus&operator=&color=Black
&model=128GB&ajax=1&nocache=$time&nobb=false
&notarget=false&noradioshack=false&nostock=false

That actually is a line from the php code I wrote to automate the checking. $time is basically

php $time = time();

This URL returns JSON with all the apple stores on the world basically and those Apple Stores have properties like “live” which indicates the availability of the iPhone in that store.

One more thing… I had to do was to get the integer identifier of the Apple Store I was interested in but that was really easy but just finding it on the map and clicking on it revealed the name and the identifier. So here is my PHP code that checks for the availability of the iPhone I was interested in:

<?php
	$store_id = "YOUR_STORE_ID";
	while (1) {
		$time = time();
		echo "[i] Checking at $time\n";
		$url = "http://www.istocknow.com/live/live.php?type=7plus&operator=&color=Black&model=128GB&ajax=1&nocache=$time&nobb=false&notarget=false&noradioshack=false&nostock=false";
		echo "[i] URL: $url\n";
		$json = file_get_contents($url);
		$json = json_decode($json,true);
		if (isset($json["dataz"])) {
			$data = $json["dataz"];
			echo "[i] Got Data\n";
			if (array_key_exists($store_id,$data)) {
				echo "[i] Found Store $store_id\n";
				$store_json = $data[$store_id];
				if (intval($store_json["live"]) == 1) {
					echo "[i] Found an iPhone for you!\n";
					$title = $store_json["title"] ?: "your local AS"
					mail("YOUR_EMAIL","iPhone available","Hi there!, $title has an iPhone for you");
				}
			}
		}
		sleep(60); //wait a minute before checking again
	}

?>

And I was right, within two days I got an email from my server telling me that an iPhone was available. I immediately purchased it and selected to pick it up while cancelling the old order that would arrive in November.

Disclaimer: I know this is php code is performing busy waiting by using CPU time (while sleeping). This is highly inefficient, but for this code being the only thing that ran on my server and I expected it to last for a few days before I could grab my iPhone, so I did not write a high performance program :P

Warning: If you want to reproduce it, please don’t spam the istocknow.com server. Make a reasonable delay between requests as if a human would do patiently waiting for an iPhone :D Also please know what you do when deploying or using the code snippet above. it was just a small POC. :)

  • Janosch (@sharedRoutine)