Skip to content

Instantly share code, notes, and snippets.

@20chan
Created June 19, 2020 09:14
Show Gist options
  • Save 20chan/5716080202fdf32987c76e73021ea03d to your computer and use it in GitHub Desktop.
Save 20chan/5716080202fdf32987c76e73021ea03d to your computer and use it in GitHub Desktop.
ifttt webhook script
#!/bin/bash
_usage() {
echo "Usage: $0 <event> [value1] [value2] [value3]"
}
if [ -z "$1" ]; then
_usage
exit 1
fi
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
KEYPATH="${SCRIPTPATH}/key"
KEY=$(cat "$KEYPATH")
EVENT_NAME=$1
URL="https://maker.ifttt.com/trigger/${EVENT_NAME}/with/key/${KEY}"
curl \
-X POST \
-H "Content-Type: application/json" \
-d $(printf '{"value1":"%q","value2":"%q","value3":"%q"}' $2 $3 $4) \
$URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment