Lock or Unlock Example

cURL command to lock your door:


curl -i -X POST "https://api.lockitron.com/locks/b708198b-3209-4005-9f9f-44ffbdc02548/lock?access_token=99e75a775fe737bb716caf88f161460bb623d283c3561c833480f0834335668b"

Python script to lock your door:


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

#define parameters
lock_uuid = 'b708198b-3209-4005-9f9f-44ffbdc02548'
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"]