public void SendGenericCommand(string commandName, params string[] values) { try { if (client == null) { return; } var address = new StringBuilder(); address.AppendFormat("https://maker.ifttt.com/trigger/{0}/with/key/{1}", commandName, Key); if (values != null && values.Length > 0) { address.Append("?"); for (var i = 0; i < values.Length; i++) { if (i > 0) { address.Append("&"); } address.AppendFormat("value{0}={1}", i + 1, values[i] ?? ""); } } var clientRequest = new HttpsClientRequest(); clientRequest.RequestType = Crestron.SimplSharp.Net.Https.RequestType.Post; clientRequest.Url.Parse(address.ToString()); var response = client.Dispatch(clientRequest); if (response != null) { CrestronConsole.PrintLine("IFTTT: " + response.ContentString); } } catch (HttpsException ex) { CrestronConsole.PrintLine("IFTTT: HTTPS Exception encoutered when sending data to IFTTT webhooks serice."); CrestronConsole.PrintLine("IFTTT: " + ex.Message); } catch (Exception ex) { CrestronConsole.PrintLine("IFTTT: Error encountered when sending data to IFTTT webhooks service."); CrestronConsole.PrintLine("IFTTT: " + ex.Message); } }
public static string SecureGet(string url) { Https.HttpsClient client = new Https.HttpsClient(); Https.HttpsClientRequest request = new Https.HttpsClientRequest(); request.Url.Parse(url); request.RequestType = HttpsRequestType.Get; request.Encoding = Encoding.ASCII; Https.HttpsClientResponse response = client.Dispatch(request); return(response.ContentString); }
private CodecResponse Dispatch(CodecRequest request) { try { var r = _client.Dispatch(request.Request); #if DEBUG Debug.WriteSuccess("Received HTTPS Response", "{0}, {1} bytes", r.Code, r.ContentLength); #endif return(new CodecResponse(request, r)); } catch (Exception e) { if (e is ThreadAbortException) { return(new CodecResponse(request, e)); } //CloudLog.Exception(e, "Error dispatching request ID {0} to codec", request.Id); return(null); } }