Created
September 18, 2015 14:17
-
-
Save agbishara/cc85c261b8c3b9ebaa69 to your computer and use it in GitHub Desktop.
Geohopper ifttt.com php tie in - Maker Channel
This file contains hidden or 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
<?php | |
$key="enter your key"; | |
function run($command,$key) { | |
$ch = curl_init(); | |
$timeout = 5; | |
$url='http://maker.ifttt.com/trigger/'.$command.'/with/key/'.$key; | |
//echo $url; | |
curl_setopt($ch, CURLOPT_URL,$url ); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
//echo $data; | |
} | |
$data_back = json_decode(file_get_contents('php://input')); | |
$event = $data_back->{"event"}; | |
//echo $event; | |
if($event){ | |
if($event=="LocationExit"){ | |
run("LOFF",$key); | |
run("ACOFF",$key); | |
}else if($event=="LocationEnter"){ | |
run("LON",$key); | |
run("ACON",$key); | |
} | |
//echo "<script>var postinput=".$event."</script>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment