Skip to content

Instantly share code, notes, and snippets.

@hmans
Created August 10, 2012 11:46
Show Gist options
  • Save hmans/3313741 to your computer and use it in GitHub Desktop.
Save hmans/3313741 to your computer and use it in GitHub Desktop.
Facebook signed_request + Rails (with Koala)
class ApplicationController < ActionController::Base
protect_from_forgery
def fb_liked?
session[:signed_request]['page']['liked'] if session[:signed_request]
end
def fb_admin?
session[:signed_request]['page']['admin'] if session[:signed_request]
end
helper_method :fb_liked?, :fb_admin?
before_filter do
if params[:signed_request]
oauth = Koala::Facebook::OAuth.new(ENV['FB_APP_ID'], ENV['FB_APP_SECRET'])
session[:signed_request] = oauth.parse_signed_request(params[:signed_request])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment