Skip to content

Instantly share code, notes, and snippets.

@vivahiraj
Created April 26, 2016 13:55
Show Gist options
  • Save vivahiraj/85876c1aa82c9a1a43e874e1182902e8 to your computer and use it in GitHub Desktop.
Save vivahiraj/85876c1aa82c9a1a43e874e1182902e8 to your computer and use it in GitHub Desktop.
LINE BOT APIでメッセージ送信
# coding: utf-8
require 'rest-client'
require 'json'
ID = "Channel ID"
SECRET = "Channel Secret"
MID = "MID"
TO = "送信先のID"
headers = {
"Content-Type" => "application/json; charser=UTF-8",
"X-Line-ChannelID" => ID,
"X-Line-ChannelSecret" => SECRET,
"X-Line-Trusted-User-With-ACL" => MID
}
params = {
to: [TO],
toChannel: "1383378250",
eventType: "138311608800106203",
content: {
contentType: 1,
toType: 1,
text: "てすとbot",
}
}
p params.to_json
begin
RestClient.post "https://trialbot-api.line.me/v1/events", params.to_json, headers
rescue => e
p e.response
exit
end
p "send ok"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment