Created
August 10, 2012 11:46
-
-
Save hmans/3313741 to your computer and use it in GitHub Desktop.
Facebook signed_request + Rails (with Koala)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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