JSON、コールバック、および Webhook は初めてなので、助けていただければ幸いです。
ここで Venmo の Webhook ( https://developer.venmo.com/docs/webhooks ) を使用して JSON を収集し、heroku の Rails アプリのデータベースに保存します。
アクションの設定方法に関するヘルプはreceive
、非常に役立ちます。
私のコントローラー:
class WebhooksController < ApplicationController
skip_before_filter :verify_authenticity_token
def receive
end
def verify
#venmo verification
render text: params[:venmo_challenge]
end
end
私のルート:
post '/webhooks/receive' => 'webhooks#receive'
get '/webhooks/receive' => 'webhooks#verify'
私のherokuログ
2014-11-17T23:42:54.770290+00:00 heroku[web.1]: State changed from starting to up
2014-11-17T23:43:41.105707+00:00 heroku[router]: at=info method=POST path="/webhooks/receive" host=infinite-badlands-3074.herokuapp.com request_id=0ad13de0-f44c-4de3-b068-1e82800c770a fwd="184.73.153.84" dyno=web.1 connect=1ms service=79ms status=200 bytes=1145
2014-11-17T23:43:41.032647+00:00 app[web.1]: Started POST "/webhooks/receive" for 184.73.153.84 at 2014-11-17 23:43:41 +0000
2014-11-17T23:43:41.100217+00:00 app[web.1]: Rendered webhooks/receive.html.erb within layouts/application (1.2ms)
2014-11-17T23:43:41.090310+00:00 app[web.1]: Processing by WebhooksController#receive as */*
2014-11-17T23:43:41.090341+00:00 app[web.1]: Parameters: {"date_created"=>"2014-11-17T17:22:51.414052", "type"=>"payment.created", "data"=>{"status"=>"settled", "id"=>"1"}, "webhook"=>{}}
2014-11-17T23:43:41.090879+00:00 app[web.1]: WARNING: Can't verify CSRF token authenticity
2014-11-17T23:43:41.102859+00:00 app[web.1]: Completed 200 OK in 12ms (Views: 11.6ms | ActiveRecord: 0.0ms)