// /blink1/input/ifttt -- Add and Start watching messages from IFTTT webservice static string Ublink1InputIfttt(HttpRequest request, Blink1Server blink1Server) { string pname = request.Query.Get("pname"); string iname = request.Query.Get("iname"); string rulename = request.Query.Get("arg1"); string test = request.Query.Get("test"); if (pname == null) { pname = iname; } Boolean testmode = (test == null) ? false : (test.Equals("on") || test.Equals("true")); string statusstr = "must specifiy 'iname' and 'arg1' (rulename)"; Blink1Input input = null; if (rulename != null && iname != null) { statusstr = "input ifttt"; rulename = rulename.Trim(); input = new Blink1Input(blink1Server, iname, pname, "ifttt", rulename); if (testmode) // override periodic fetch for immediate fetch { Blink1Input.getIftttResponse(false); } input.updateIftttInput(); if (!testmode) { blink1Server.inputs[iname] = input; // NOTE: this replaces input if already exists } } blink1Server.saveSettings(); Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("status", statusstr); result.Add("input", input); return(JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings)); }
// /blink1/input/ifttt -- Add and Start watching messages from IFTTT webservice static string Ublink1InputIfttt(HttpRequest request, Blink1Server blink1Server) { string pname = request.Query.Get("pname"); string iname = request.Query.Get("iname"); string rulename = request.Query.Get("arg1"); string test = request.Query.Get("test"); if (pname == null) pname = iname; Boolean testmode = (test == null) ? false : (test.Equals("on") || test.Equals("true")); string statusstr = "must specifiy 'iname' and 'arg1' (rulename)"; Blink1Input input = null; if (rulename != null && iname != null) { statusstr = "input ifttt"; rulename = rulename.Trim(); input = new Blink1Input(blink1Server, iname, pname, "ifttt", rulename); if (testmode) { // override periodic fetch for immediate fetch Blink1Input.getIftttResponse(false); } input.updateIftttInput(); if (!testmode) { blink1Server.inputs[iname] = input; // NOTE: this replaces input if already exists } } blink1Server.saveSettings(); Dictionary<string, object> result = new Dictionary<string, object>(); result.Add("status", statusstr); result.Add("input", input); return JsonConvert.SerializeObject(result, Formatting.Indented, jsonSerializerSettings); }