-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Facebook profile picture #80
Comments
@Salma7amed, try with a code like this from requests import request, HTTPError
from django.core.files.base import ContentFile
def save_profile_picture(strategy, user, response, details, is_new=False,
*args, **kwargs):
# Save Facebook profile photo into a user profile, assuming a profile model
# with a profile_photo file-type attribute
if is_new and strategy.backend.name == 'facebook':
url = 'http://graph.facebook.com/{0}/picture'.format(response['id'])
try:
response = request('GET', url, params={'type': 'large'})
response.raise_for_status()
except HTTPError:
pass
else:
profile = user.get_profile()
profile.profile_photo.save('{0}_social.jpg'.format(user.username),
ContentFile(response.content))
profile.save() Put that into the pipeline and it should do the trick. The code wasn't tested, but should help to get you started). |
Thanks a lot it did work (Y). |
What if we have the ImageField instead of FileField ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a question, How to store the facebook profile picture of a user while logging in through facebook.
I found this link which says how to do so using django-social-app, https://gist.github.com/kalamhavij/1662930.
How can I do the same using python-social-app ??
The text was updated successfully, but these errors were encountered: