Lock or Unlock Example

cURL command to lock your door:


curl -i -X POST "https://api.lockitron.com/locks/69b62810-4d5e-404b-999c-353e1431c522/lock?access_token=99e75a775fe737bb716caf88f161460bb623d283c3561c833480f0834335668b"

Python script to lock your door:


#! /usr/bin/python
import urllib
import json

#define parameters
lock_uuid = '69b62810-4d5e-404b-999c-353e1431c522'
access_token = '99e75a775fe737bb716caf88f161460bb623d283c3561c833480f0834335668b'

#change this to 'unlock' to unlock door
command = 'lock'

#encode parameters so we can POST
params = urllib.urlencode({'access_token': access_token})
url = "https://api.lockitron.com/locks/" + lock_uuid + "/" + command

#submit the request
response = json.load(urllib.urlopen(url, params))

#parse the response
print response["log"]["result"]
print response["log"]["human_result"]