Last active
April 20, 2018 09:51
-
-
Save markeverard/64017b1c3d6e8a8c4488 to your computer and use it in GitHub Desktop.
Class containing a method to send a webhook to the IFTTT Maker channel
This file contains 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
using System.Net; | |
namespace Scenarios | |
{ | |
public class MakerChannelWebHookSender | |
{ | |
private string iftttApiKey = "sign-up-to-ifttt-to-get-a-key"; | |
public void Send(string eventName, string value1, string value2, string value3) | |
{ | |
var urlFormat = "https://maker.ifttt.com/trigger/{0}/with/key/{1}{2}"; | |
var queryValues = string.Empty; | |
if (!string.IsNullOrEmpty(value1)) | |
{ | |
queryValues = "?" + value1; | |
if (!string.IsNullOrEmpty(value2)) | |
queryValues += string.Concat("&",value2); | |
if (!string.IsNullOrEmpty(value3)) | |
queryValues += string.Concat("&", value3); | |
} | |
var url = string.Format(urlFormat, eventName, iftttApiKey, queryValues); | |
WebRequest request = WebRequest.Create(url); | |
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment