Skip to content

Instantly share code, notes, and snippets.

@taylanpince
Created October 18, 2014 21:05
Show Gist options
  • Save taylanpince/b16c35eea1aada8d6712 to your computer and use it in GitHub Desktop.
Save taylanpince/b16c35eea1aada8d6712 to your computer and use it in GitHub Desktop.
iPhone Availability Checker
import urllib2
import json
from twilio.rest import TwilioRestClient
EATON_STORE_CODE = "R121"
IPHONE6_SILVER_128_CODE = "MG3F2CL/A"
IPHONE6_GREY_128_CODE = "MG3E2CL/A"
APPLE_RESERVATION_URL = "https://reserve.cdn-apple.com/CA/en_CA/reserve/iPhone/availability.json"
TWILIO_ACCCOUNT_SID = "<TWILIO_SID>"
TWILIO_AUTH_TOKEN = "<TWILIO_AUTH_TOKEN>"
TWILIO_ACCOUNT_NUMBER = "<TWILIO_NUMBER>"
NOTIFY_PHONE_NUMBER = "<YOUR_PHONE_NUMBER>"
def check_status():
print "Checking..."
response = urllib2.urlopen(APPLE_RESERVATION_URL)
doc = json.load(response)
store_info = doc[EATON_STORE_CODE]
silver_status = store_info[IPHONE6_SILVER_128_CODE]
if not silver_status:
print "No phones available"
return
print "Delivering SMS..."
sms_client = TwilioRestClient(TWILIO_ACCCOUNT_SID, TWILIO_AUTH_TOKEN)
sms_client.messages.create(
body="iPhones are available!",
to=NOTIFY_PHONE_NUMBER,
from_=TWILIO_ACCOUNT_NUMBER
)
if __name__ == "__main__":
check_status()
@taylanpince
Copy link
Author

This is specific to Eaton Centre in Toronto but can be updated for most locations, here it the actual form: https://reserve.cdn-apple.com/CA/en_CA/reserve/iPhone/availability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment