Search code examples
ruby-on-railsrubyfacebook-graph-apiinstagram-api

Instagram Webhook for Ruby on Rails


The documentation for webhook is in javascript and i am looking for rails code.

app.post('/instagram', function(req, res) {
  console.log('Instagram request body:');
  console.log(req.body);
  // Process the Instagram updates here
  received_updates.unshift(req.body);
  res.sendStatus(200);
});

'req.body', How do i type that in the rails controller?

Here is the link to the entire sample project for webhook. https://github.com/fbsamples/graph-api-webhooks-samples/blob/master/heroku/index.js

I am trying to get the comments in Instagram Media posts.


Solution

  • RestClient

    require 'rest-client'
    
    response = RestClient.post('/instagram')
    response.body
    

    Net::HTTP

    require 'net/http'
    
    response = Net::HTTP.post_form(URI('/instagram'))
    response.body