Created
May 22, 2017 06:18
-
-
Save KMR-zoar/dcc45479c4a7e79f4fb08efe49fc8e3d 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
require 'net/http' | |
require 'uri' | |
require 'json' | |
text = "Hello Slack!" | |
data = { "text" => text } | |
webhook_uri = "%Slack WebHooks URI%" | |
parsed_uri = URI.parse(webhook_uri) | |
res = Net::HTTP.post_form( | |
parsed_uri, | |
{ "payload" => data.to_json } | |
) | |
case res | |
when Net::HTTPSuccess, Net::HTTPRedirection | |
exit 0 | |
else | |
res.value | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment