Skip to content

Instantly share code, notes, and snippets.

@KMR-zoar
Created May 22, 2017 06:18
Show Gist options
  • Save KMR-zoar/dcc45479c4a7e79f4fb08efe49fc8e3d to your computer and use it in GitHub Desktop.
Save KMR-zoar/dcc45479c4a7e79f4fb08efe49fc8e3d to your computer and use it in GitHub Desktop.
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