How do I trigger an event from a Bash shell script

This solution was taken from this StackOverflow answer.

Please note that it is essential that you validate the parameters you are sending if the content of your events are user generated.

Please also note that the channel name, event name and event data used in the following example is hard-coded and you would need to extract that into a parameter.



timestamp=$(date +%s)
# Be sure to use `printf %s` to prevent a trailing \n from being added to the data.
md5data=$(printf '%s' "$data" | md5)


# Be sure to use a multi-line, double quoted string that doesn't end in \n as 
# input for the SHA-256 HMAC.
authSig=$(printf '%s' "POST
$queryString" | openssl dgst -sha256 -hex -hmac "$secret")

curl -H "Content-Type:application/json" -d "$data" "${path}?${queryString}&auth_signature=${authSig}"
Was this article helpful?
1 out of 1 found this helpful
Haven't found what you were looking for?
Submit a ticket