LoginSignup
0
0

Rubyでgemを使わずにSlackにメッセージを送信する

Posted at

目的

gemを使わないでSlackにメッセージを送ります。

コード

main.rb
require 'net/http'
require 'uri'

uri = URI.parse('https://slack.com/api/chat.postMessage')
params = {
  channel: '#random',
  icon_emoji: ':robot_face:',
  username: 'bot',
  token: ENV['SLACK_API_TOKEN'],
  text: "予定表~①💖ハンカクだ",
}
res = Net::HTTP.post_form(uri, params)
pp res
pp res.body
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0