This article shows how to send a notification to Android or iOS devices with Maker channel.
You need IFTTT account and any Android or iOS device with the IF app installed.


1. Create a recipe



Click this and search Maker channel.



1.1 Step 1

- Choose Maker icon and click Connect and then Done.







1.2 Step 2 ~ 3

- Click Continue to the next step and Receive a web request.
- Enter a event name. In this demo, I create SWITCH event.




1.3 Step 4 ~ 5

- Click that and search Notification and choose IF Notification.
- Choose Send a notification action.




1.4 Step 6

- There are four properties for this action.
- EventName is the trigger name. Value1 ~ 3 are user defined values. OccuredAt is the time when the trigger is fired.



- I changed the text like below.

Click image for larger version  Name:	007.png Views:	1 Size:	45.9 KB ID:	118


1.5 Step 7

- Click Create Recipe.

Click image for larger version  Name:	008.png Views:	2 Size:	39.4 KB ID:	122


2. How to trigger event

- Go to the Maker channel.

Click image for larger version  Name:	009.png Views:	1 Size:	74.9 KB ID:	119

- A key in the “Your key is” section is very important. You need the key to trigger your event.
- Click How to Trigger Events.

Click image for larger version  Name:	010.png Views:	1 Size:	83.3 KB ID:	121

- An event triggered by HTTP POST or GET web request.
- Fill {event}, “value1”, “value2”, “value3” and then click Test it then you can receive a notification on your device IF app installed.

Click image for larger version  Name:	011.png Views:	1 Size:	94.8 KB ID:	120

3. Demo



4. Source Code

- ifttt.php
PHP Code:
<?php

include_once "/lib/sn_dns.php";

function 
ifttt_maker($event$value1$value2$value3)
{
    
$host_name "maker.ifttt.com";

    
$host_addr dns_lookup($host_nameRR_A);

    if(
$host_addr == $host_name)
        
$host_addr dns_lookup($host_nameRR_A);

    if(
$host_addr == $host_name)
        exit 
"$host_name : Not Found\r\n";

    
$tcp0_pid pid_open("/mmap/tcp0");

    
pid_bind($tcp0_pid""0);

    
error_log("connect to $host_addr:80...");
    
pid_connect($tcp0_pid$host_addr80);

    for(;;)
    {
        
$state pid_ioctl($tcp0_pid"get state");

        if(
$state == TCP_CLOSED)
            
pid_connect($tcp0_pid$host_addr80);

        if(
$state == TCP_CONNECTED)
            break;
    }

    
error_log("connected\r\n");

    
$msg "";
    if(
$value1 != "" || $value2 != "" || $value3 != "")
    {
        
$msg "{";

        if(
$value1 != "")
            
$msg .= ""value1" : "".$value1."",";

        if(
$value2 != "")
            
$msg .= ""value2" : "".$value2."",";

        if(
$value3 != "")
            
$msg .= ""value3" : "".$value3."",";

        
$msg substr($msg0strlen($msg) - 1);

        
$msg .= " }";
    }

    
$http_req  "POST /trigger/".$event."/with/key/YOUR_KEY HTTP/1.1\r\n";
    
$http_req .= "Host: $host_name\r\n";
    
$http_req .= "Content-Type: application/json\r\n";

    if(
strlen($msg) > 0)
        
$http_req .= sprintf("Content-Length: %d"strlen($msg));

    
$http_req .= "\r\n\r\n";

    if(
strlen($msg) > 0)
        
$http_req .= $msg;

    
error_log($http_req);

    
$sent pid_send($tcp0_pid$http_req);

    
$rbuf "";
    for(;;)
    {
        
$temp "";
        
$read pid_recv($tcp0_pid$temp);
        if(
$read 0)
            
$rbuf .= $temp;

        if(
strpos($rbuf"\r\n\r\n") !== FALSE)
            break;

        if(
pid_ioctl($tcp0_pid"get state") == TCP_CLOSED || pid_ioctl($tcp0_pid"get state") == SSL_CLOSED)
            break;
    }
    
pid_close($tcp0_pid);
    
error_log($rbuf);
    
error_log("\r\nconnection closed\r\n");
}

?>
- task0.php
PHP Code:
<?php

include_once "/lib/sd_340.php";
include_once 
"ifttt.php";

echo 
"PHPoC example : IFTTT maker channel.\r\n";

$switch_state 0;

uio_setup(00"in");

while(
1)
{
    
$state uio_in(00);
    if(
$switch_state != $state)
    {
        
$value1 "";
        
$switch_state $state;
        if(
$switch_state == 0)
            
$value1 "OFF";
        else if(
$switch_state == 1)
            
$value1 "ON";

        
ifttt_maker("SWITCH"$value1"""");
    }
}

?>
Attached Files