Skip to content

Instantly share code, notes, and snippets.

@mikepence
Created October 25, 2012 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikepence/3953451 to your computer and use it in GitHub Desktop.
Save mikepence/3953451 to your computer and use it in GitHub Desktop.
Code to fetch Facebook image for Catarse (latest code)
def self.create_with_omniauth(auth)
create! do |user|
user.provider = auth["provider"]
user.uid = auth["uid"]
user.name = auth["info"]["name"]
user.email = auth["info"]["email"]
user.email = auth["extra"]["user_hash"]["email"] if auth["extra"] and auth["extra"]["raw_info"] and user.email.nil?
user.nickname = auth["info"]["nickname"]
user.bio = auth["info"]["description"][0..139] if auth["info"]["description"]
user.locale = I18n.locale.to_s
if auth["provider"] == "twitter"
user.image_url = "https://api.twitter.com/1/users/profile_image?screen_name=#{auth['info']['nickname']}&size=original"
end
if auth["provider"] == "facebook"
user.image_url = "https://graph.facebook.com/#{auth['uid']}/picture?type=large"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment