How to use Facebook registration plugin

Hi, I want to implement sign in with Facebook in my Rails web application. I red about it from https://developers.facebook.com/docs/plugins/registration/.

My problem is I am not getting how to get the users data from signed request into my database. Please help me.

Thanks in advance!

Answers


this is the iframe code change the client_id and redirect_url with yours client id and redirect_url

<iframe src="https://www.facebook.com/plugins/registration?
             client_id=MY_CLIENT_ID&
             redirect_uri=MY_REDIRECT_URI&
             fields=name,email,first_name,last_name"
        scrolling="auto"
        frameborder="no"
        style="border:none"
        allowTransparency="true"
        width="100%"
        height="330">
</iframe>

it will automatically call the redirect_url provided here after clicking the register . in that method facebook will return you one variable "signed_request" that contains all the data for users. in the method you can decode the signed request . this is my code to decode the signed request

def decode_facebook_hash(signed_request)
  signature, str = signed_request.split('.')
  str += '=' * (4 - str.length.modulo(4))
  ActiveSupport::JSON.decode(Base64.decode64(str.gsub("-", "+").gsub("_", "/")))
end

You can use the OmniAuth gem.

A railscast tutorial is available here: http://railscasts.com/episodes/241-simple-omniauth


Need Your Help

Excel /VBA : find constants in range with a formula

excel vba excel-vba excel-2010

I am trying to setup a formula in excel/vba that will allow me to input a range of cells and output in one cell whether or not there are any constants in that range. Its real easy to do for one cel...

wsimport with special character and Xauthfile

web-services ssl soapui wsimport xauth

I'm facing the same problem that this guy here: