Last active
December 1, 2018 09:25
-
-
Save bathtimefish/c405c22c9eebb5fb1f534b8ba59fcea9 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF8"> | |
<title>Send mail when webpage opened</title> | |
</head> | |
<body> | |
<script> | |
window.onload = function() { | |
var event_name = 'webpage_opened'; | |
var webhook_key = '[webhook key]'; | |
var webhook_url = 'https://maker.ifttt.com/trigger/' + event_name + '/with/key/' + webhook_key; | |
var json = JSON.stringify({"value1":"a","value2":"b","value3":"c"}); | |
console.info('Try to request to webhook...', json); | |
var options = { | |
method: 'POST', | |
headers: { 'Content-Type': 'application/json' }, | |
body: json | |
}; | |
fetch(webhook_url, options).then(function(res) { | |
return res.text(); | |
}).then(function(text) { | |
console.log('SUCCESS:', text); | |
}).catch(function(e) { | |
console.error('ERROR:', e); | |
}); | |
// setInterval(function() { | |
// fetch(webhook_url, options).then(function() { | |
// console.info('Triggered webhook'); | |
// }).catch(function(e) { | |
// console.error('ERROR:', e); | |
// }); | |
// }, 5000); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment