-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
31 lines (26 loc) · 904 Bytes
/
Copy pathapp.rb
File metadata and controls
31 lines (26 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'sinatra/base'
require 'json'
require 'rest-client'
class App < Sinatra::Base
post 'linebot/callback' do
params = JSON.parse(request.body.read)
params['result'].each do |msg|
request_content = {
to: [msg['content']['from']],
toChannel: 1383378250, # Fixed value
eventType: "138311608800106203", # Fixed value
content: msg['content']
}
endpoint_uri = 'https://traialbot-api.line.me/v1/events'
content_json = request_content.to_json
RestClient.proxy = ENV['FIXIE_URL'] if ENV['FIXIE_URL']
RestClient.post(endpoint_uri, content_json, {
'Content-Type' => 'application/json; charset=UTF-8',
'X-Line-ChannelID' => ENV["LINE_CHANNEL_ID"],
'X-Line-ChannelSecret' => ENV["LINE_CHANNEL_SECRET"],
'X-Line-Trusted-User-With-ACL' => ENV["LINE_CHANNEL_MID"],
})
end
"OK"
end
end