Skip to content

Instantly share code, notes, and snippets.

@renlight10
Forked from guangrei/ifttt.php
Created January 13, 2017 15:21
Show Gist options
  • Select an option

  • Save renlight10/3b44124e7d5063a586a4f1f844a9f8da to your computer and use it in GitHub Desktop.

Select an option

Save renlight10/3b44124e7d5063a586a4f1f844a9f8da to your computer and use it in GitHub Desktop.
Send Event to IFTTT
<?php
//configuration
$key="API key";
$event="event_name";
//data
$data=json_encode(array( "value1"=>"data for value1","value2"=>"data for value2","value3"=>"data for value3"));
//process
$url="https://maker.ifttt.com/trigger/$event/with/key/$key";
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
curl_close($ch);
//show result
echo "<pre>$result</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment