Created
October 25, 2012 15:40
-
-
Save mikepence/3953451 to your computer and use it in GitHub Desktop.
Code to fetch Facebook image for Catarse (latest code)
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
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