Created
November 6, 2012 01:50
-
-
Save mculp/4021973 to your computer and use it in GitHub Desktop.
what is wrong with this picture? getting larger photo from linked in
This file contains hidden or 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
| gem 'linkedin' |
This file contains hidden or 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
| LinkedIn.configure do |config| | |
| config.token = "..." | |
| config.secret = "..." | |
| end |
This file contains hidden or 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 grab_photo(user) | |
| photo_url = case @omniauth_data['provider'] | |
| when 'facebook' | |
| provider.info.image | |
| when 'twitter' | |
| provider.info.image.gsub(/_normal\./, '') | |
| when 'linkedin' | |
| client = LinkedIn::Client.new | |
| client.authorize_from_access(@omniauth_data['credentials']['token'], @omniauth_data['credentials']['secret']) | |
| client.profile(:fields => ['picture-urls::(original)']).picture_urls.all.first | |
| end | |
| user.profile.photo.download!(photo_url) unless user.profile.photo | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apparently, you have to make an additional API call to LinkedIn just to grab the originally-sized photo. Ridiculous.