LoginSignup
7
5

More than 5 years have passed since last update.

LINE NotifyでLINEにポストするだけの簡単なRubyスクリプト

Posted at

LINE Notifyのページでアクセストークンを発行しておく。

require 'net/http'

uri = URI.parse("https://notify-api.line.me/api/notify")
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true

req = Net::HTTP::Post.new(uri.request_uri)
req["Authorization"] = "Bearer #{あなたのアクセストークン}"
req["Content-Type"] = 'application/x-www-form-urlencoded;charset=UTF-8'
req.set_form_data({message: 'テスト'})

res = https.request(req)
7
5
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
7
5