Skip to content

Instantly share code, notes, and snippets.

@markeverard
Last active April 20, 2018 09:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markeverard/64017b1c3d6e8a8c4488 to your computer and use it in GitHub Desktop.
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
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