No POST from facebook using real-time updates in Rails, Heroku and Koala No POST from facebook using real-time updates in Rails, Heroku and Koala heroku heroku

No POST from facebook using real-time updates in Rails, Heroku and Koala


You need to respond to the GET request with a challenge response. I have the same route for both POST and GET requests and use the following code:

route:

match "facebook/subscription", :controller => :facebook, :action => :subscription, :as => 'facebook_subscription', :via => [:get,:post]

controller:

  def realtime_request?(request)    ((request.method == "GET" && params['hub.mode'].present?) ||        (request.method == "POST" && request.headers['X-Hub-Signature'].present?))  end  def subscription    if(realtime_request?(request))      case request.method      when "GET"        challenge = Koala::Facebook::RealtimeUpdates.meet_challenge(params,'SOME_TOKEN_HERE')        if(challenge)          render :text => challenge        else          render :text => 'Failed to authorize facebook challenge request'        end      when "POST"        case params['object']        # Do logic here...        render :text => 'Thanks for the update.'      end    end  end

That should get you going with things... Note that to make a subscription I am using this:

@access_token ||= Koala::Facebook::OAuth.new(FACEBOOK_API_KEY,FACEBOOK_API_SECRET).get_app_access_token@realtime = Koala::Facebook::RealtimeUpdates.new(:app_id => FACEBOOK_API_KEY, :app_access_token => @access_token)@realtime.subscribe('user', 'first_name,uid,etc...', facebook_subscription_url,'SOME_TOKEN_HERE')

I think the key is that you properly respond to the GET request from Facebook. They use this to verify that they are contacting the correct server prior to sending confidential info about their users.

Also -- its been a while since I've looked at this, but if I remember correctly, I seem to recall having issues with anything besides default protocol port specifications within the callback URL. Ex: http://www.something.com:8080/subscription did not work -- it had to be http://www.something.com/subscription


Not sure if this might be the case with you, but make sure that you have permissions to access the object -user, permissions, page- properties (location, email, etc.)

In my case, I was trying to get notifications for changes on the location property without my app requiring the user_location permission. For the user object, look at the Fields section in this page https://developers.facebook.com/docs/reference/api/user/


Does Facebook know where your application is? Does it have a URL that it can resolve?