Skip to content

Instantly share code, notes, and snippets.

@brentsowers1
Created March 6, 2014 02:30
Show Gist options
  • Save brentsowers1/9381102 to your computer and use it in GitHub Desktop.
Save brentsowers1/9381102 to your computer and use it in GitHub Desktop.
Example of using Facebooker
# Unique Facebook ID of this user
facebook_id = current_facebook_user.id
# The OAuth token, this is how you access the user at a later point
token = current_facebook_client.access_token
# OAuth token expiration. Save this off, you'll need this to recreate
# the user later
expiration = current_facebook_client.expiration.to_i
name = current_facebook_user.name
# Gets an array of Mogil::Users
friends = current_facebook_user.friends
# Save facebook_id, token, and expiration to the database
# at some later point....
# load access token and expiration from database
client = Mogli::Client.new(access_token, expiration)
# User will be able to do everything that you can from the above steps,
# assuming that the access token is still valid (usually if the user
# has given your app the offline_access permission)
user = Mogli::User.find(facebook_id, client)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment