If your facebook app is asking for user permissions, and they have authorized it, the signed_request parameter that is passed to your rails app should contain the details you need. So what you can do is decode the parameter, and grab the facebook user id from the hash itself.
Try something like this:
class ApplicationController before_filter :inspect_signed_request protected def base64_url_decode(input) input += ('=' * (4 - input.length % 4) % 4) Base64.decode64(input.tr('-_', '+/')) end def inspect_signed_request encoded_sig, payload = params[:signed_request].split('.', 2) # decode the data sig = base64_url_decode(encoded_sig) data = JSON.parse(self.class.base64_url_decode(payload)) raise data.inspect end end
That will basically raise an exception, showing you the details of the signed request. Essentially, you can just parse it out as such, and check for the signed request FB ID value. If it's not there, you can add some code to redirect them to the login form instead.
martin henderson mlk day golden globes 2012 winners golden globes 2012 red carpet golden globes red carpet nfc championship game martin luther king jr quotes
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.