androng

Door Lock Agent

Feb 15th, 2014
954
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const FEED_ID = "";
  2. const API_KEY = "";
  3.  
  4. function send_xively(data){
  5.     /* A JSON request is composed of URL, headers and body. Use one line for each. */
  6.     local xively_url = "https://api.xively.com/v2/feeds/" + FEED_ID + ".json";      //format xively url
  7.     local headers = {"X-ApiKey":API_KEY, "Content-Type":"application/json", "User-Agent":"xively-Imp-Lib/1.0"};
  8.     local body = http.jsonencode(data);
  9.     // server.log(body);
  10.    
  11.     /* send data to your web service */
  12.     local response = http.put(xively_url, headers, body).sendsync();
  13.    
  14.     if(response.statuscode != 200) {
  15.         server.log("error sending message: " + response.body);
  16.     }
  17.     // server.log("#####RESPONSE#####");
  18.     // server.log(response.statuscode + " OK");     //status
  19.     // server.log(response.body);                   //body
  20. }
  21. /** Prepares to send to Xively */
  22. device.on("accessLog", function(s){
  23.     local dataToSend = {
  24.         version = "1.0.0",
  25.         datastreams = [
  26.         {
  27.             id = "AccessLog",
  28.             current_value = s
  29.         }
  30.         ]
  31.     }
  32.    
  33.     send_xively(dataToSend);
  34. });
  35. /** Prepares to send to Xively */
  36. device.on("unlockedLog", function(s){
  37.     local dataToSend = {
  38.         version = "1.0.0",
  39.         datastreams = [
  40.         {
  41.             id = "UnlockedLog",
  42.             current_value = s
  43.         }
  44.         ]
  45.     }
  46.    
  47.     send_xively(dataToSend);
  48. });
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×