Giuseppe Parrello

 

How to send an IFTTT event


In this page I provide you with script codes in order to send an IFTTT event. Please take note of the following requirements:

Be sure to keep the webhook URLs to yourself, do not share them on social networks, as anyone can use the URL to launch your IFTTT applet.


Bash language

#!/bin/bash

apikey=""
event="button_pressed"
value1="My value 1"
value2="My value 2"
value3="My value 3"

request_body=$(cat <<EOF
  {
  "value1": "$value1",
  "value2": "$value2",
  "value3": "$value3"
  }
EOF
)

echo $request_body

header="Content-Type: application/json"

/opt/bin/curl -v -i -X POST -H "$header" -d "$request_body" "https://maker.ifttt.com/trigger/$event/with/key/$apikey"

 

PHP language

<?php

$apikey = "";
$event  = "button_pressed";
$value1 = "My value 1";
$value2 = "My value 2";
$value3 = "My value 3";

$ch = curl_init();

$postdata = json_encode([
                         "value1" => $value1,
                         "value2" => $value2,
                         "value3" => $value3,
                         ]);

$header = array();
$header[] = "Content-Type: application/json";

curl_setopt($ch,CURLOPT_URL, "https://maker.ifttt.com/trigger/$event/with/key/$apikey");
curl_setopt($ch,CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($ch);

print_r($result);
print_r("\r\n\r\n");

curl_close($ch);
?>

 

Python language

import requests

apikey = ""
event  = "button_pressed"
value1 = "Test001-value1"
value2 = "Test001-value2"
value3 = "Test001-value3"

url     = "https://maker.ifttt.com/trigger/%s/with/key/%s" % (event, apikey)
payload = { "value1" : value1, "value2" : value2, "value3" : value3 }
headers = {}
res     = requests.post(url, data=payload, headers=headers)