Facebook Connect: capturing user data with django-profiles and django-socialregistration

柔情痞子 提交于 2019-12-02 16:26:18

In facebook_js.html you need to adjust the following line, by uncommenting items that you need to get from FB:

     FB.login(handleResponse/*,{perms:'publish_stream,sms,offline_access,email,read_stream,status_update,etc'}*/);

Then, in FacebookMiddleware you can extract that data from fb_user, like this:

     facebook.GraphAPI(fb_user['access_token']).get_object('me')

FWIW, I just found this moderately helpful nugget from the app author buried in the "Issues" section on github:

question from "tolano":

I have a profile model associated with the users, and everytime the user is created the profile should be created also. Should we create a new custom setup view for this purpose?

I'm finding several problems because the documentation is poor. Thank you very much.

answer from "flashingpumpkin":

Yes. Ideally you'll overwrite the setup view with your own. An easier method to adjust what is done on user creation is to pass a custom form into the setup view. You'll do that by overriding the standard url.

Here's another relevant nugget (source: http://github.com/flashingpumpkin/django-socialregistration/issues/closed#issue/7) Enough of these and this page will become the de facto django-socialregistration documentation ;)

question from "girasquid":

Maybe I'm just missing something, but I'm stuck here - is there a way to 'connect' accounts on other sites to an already-existing user?

For example, I've already signed up on Really Awesome Website, so I don't need to sign up again - but I'd like to connect my Facebook and Twitter accounts so that I can sign in with those as well.

Is there a way to do this already? If there isn't...how would I do it?

answer from "flashingpumpkin":

Yes there is. Just use the same template tags for Facebook Connect as you would for registration. Depending on if the user is already logged in or not it will create just the FacebookProfile object and link it to the existing user - or create both, the User object and the FacebookProfile object.

Have a look here:
http://github.com/flashingpumpkin/django-socialregistration/blob/master/socialregistration/templates/socialregistration/facebook_button.html and

http://github.com/flashingpumpkin/django-socialregistration/blob/master/socialregistration/templatetags/facebook_tags.py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!