Last active
December 26, 2015 17:49
-
-
Save StuffAndyMakes/7189930 to your computer and use it in GitHub Desktop.
Agent code for iPotti #2 bathroom availability monitoring system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| device.on( "lightChanged", function( json ) { | |
| // Set URL to your web service | |
| local url = "http://somedomain.com/api/for/ipotti"; | |
| // Set Content-Type header to json | |
| local headers = { "Content-Type": "application/json" }; | |
| // encode data and log | |
| local body = http.jsonencode( json ); | |
| server.log( "JSON payload going to iPotti server: " + body ); | |
| // send data to your web service | |
| //http.post( url, headers, body ).sendsync(); | |
| // this is teh async way to do it | |
| local request = http.post( url, headers, body); | |
| request.sendasync( function ( res ) { | |
| server.log( "iPotti server returned HTTP status " + res.statuscode ); | |
| } ); | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment