This article explains how to create an IFTTT.
- Go to IFTTT.com and create a new applet. Start by searching for Webhooks
- Select Webhooks and then click on “Receive a web request”
- Enter an Event Name and then click on “Create trigger”.
- Click “+ That” to continue and add an action. That will bring up a bring “Choose Actions Service”. Search for Smart Life and click on that service.
- On the “Choose action” screen, select “Turn off”.
- Select the device that you want to turn off and then click on “Create action”.
- On the next screen, click on “Finish” to create your applet which will be called “If Maker Event “PC Speakers OFF”, then turn off Computer Speakers”.
To trigger an Event
Make a POST or GET web request to:
https://maker.ifttt.com/trigger/
(The instructions here can be found in Webhooks Documentation.) /with/key/xxxxxxxxxxxx- Substitute the string “{event}” with the name of the applet that you created in step 7.
You can use the https call in a JavaScript ajax call or directly in a PHP script.
Example Code:
HTML:
<!DOCTYPE html>
<html>
<body>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”></script>
<h1>Hello World</h1>
<script>
$.ajax({
method: “POST”,
url: “http://davenotes.com/sites/extra/PC_Speakers_Off.php”,
});
</script>
</body>
</html>
PHP:
<?
//The URL that we want to GET.
$url = “https://maker.ifttt.com/trigger/PC Speakers OFF/with/key/x-xxxxxxxxxxx”;
//Use file_get_contents to GET the URL in question.
$contents = file_get_contents($url);
?>