Skip to content

Instantly share code, notes, and snippets.

@et
Created February 6, 2018 07:13
Show Gist options
  • Save et/992faa6cf77d4199777da43f7abbf883 to your computer and use it in GitHub Desktop.
Save et/992faa6cf77d4199777da43f7abbf883 to your computer and use it in GitHub Desktop.
With POST endpoints
require 'json'
require 'sinatra'
class App < Sinatra::Base
get '/event' do
hub_challenge = params['hub.challenge']
content_type :json
{ 'hub.challenge' => hub_challenge }.to_json
end
post '/event' do
status 200
request.body.rewind
request_payload = JSON.parse(request.body.read)
p request_payload
File.open('events.txt', 'a') do |f|
f.puts(request_payload)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment