Skip to content

Instantly share code, notes, and snippets.

@guangrei
Last active November 22, 2020 10:16
Show Gist options
  • Save guangrei/b57847ffc5f9e004b337c19c37c2e77e to your computer and use it in GitHub Desktop.
Save guangrei/b57847ffc5f9e004b337c19c37c2e77e 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