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

This question is an extended version of Facebook. Updated in real time does not call our servers , which seems dead. In addition, Realtime updates the internal server error on Heroku using Koala , it does not help, because I subscribe to the heroku console, as pjaspers suggested.

I have an application ( ruby 1.9.2p290and Rails 3.1.3) that connects to facebook to get the data from the current user. Everything works fine with koala gem (v1.2.1), but I check the fb servers every time users log in. I would like to use real-time updates on facebook, and I read the following:

I installed the system in test mode and successfully deployed to the hero. I can subscribe to the user object and I get a GET request to my server, but there is no POST with updated information received from facebook . If I send POST to my server manually, everything will work.

Additional information: routes.rb

  get '/realtime' => 'realtime#verify'
  post '/realtime' => 'realtime#change'

generating

      realtime GET  /realtime(.:format) {:controller=>"realtime", :action=>"verify"}
               POST /realtime(.:format) {:controller=>"realtime", :action=>"change"}

Controller (breadboard version, only to check if it works):

class RealtimeController < ApplicationController
  def verify
    render :text => params["hub.challenge"]
  end

  def change
    puts params.inspect
    render :nothing => true
  end
end

Subscription from heroku console:

irb(main):004:0> @updates = Koala::Facebook::RealtimeUpdates.new(:app_id => ENV['FACEBOOK_APP_ID'], :secret => ENV['FACEBOOK_APP_SECRET'])
=> #<Koala::Facebook::RealtimeUpdates:0x00000004f5bca8 @app_id="XXXXXXX", @app_access_token="XXXXXXX", @secret="XXXXXXX", @graph_api=#<Koala::Facebook::API:0x00000004a8d7a8 @access_token="XXXXXXX">>

irb(main):005:0> @updates.list_subscriptions
=> [{"object"=>"user", "callback_url"=>"http://blah-blah-0000.herokuapp.com/realtime", "fields"=>["education", "email", "friends", "name", "website", "work"], "active"=>true}]

I do not know what to do next...

  • Perhaps I am not triggering the correct event changes?
  • ? ( , )
  • - ?
  • - ?
  • Facebook? ?

:)

+5
3

GET . POST GET :

:

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

:

  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

... , :

@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')

, , GET Facebook. , , .

, , , , , , -, URL- . : http://www.something.com:8080/subscription - http://www.something.com/subscription

+9

, , , -, , (, ..).

location , user_location. "" https://developers.facebook.com/docs/reference/api/user/

+3

Facebook, ? URL-, ?

+1

All Articles