views:

69

answers:

3

Either my google searching has completely left me or there's hardly any documentation/tutorials for django-socialregistration. Too bad, because it seems like a nice enough app. Through some trial-and-error, I have managed to get it mostly running on my site.

My question, using django-socialregistration how do I request permission for the facebook user's full name, current city and date of birth and store it in my UserProfile table (which is my AUTH_PROFILE_MODULE for django-profiles) in Django upon registration? Also, how do I post to the user's wall from Django once the connection is made?

Currently, when I click the "Connect with Facebook" button the facebook connection is made, a new Django user is created and the user is logged in with that Django account. However, no UserProfile is created and no facebook profile data is saved.

Any facebook connect gurus out there want to help the Django pony fly to Facebookland?

Setup:
- Django 1.2.1
- Python 2.5.2
- django-socialregistration 0.4.2
- django-registration 0.7
- django-profiles 0.2

alt text
"Kind sir, can you please help me find the magical Facebookland?"

+3  A: 

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')
Tomasz Zielinski
You've made the Django pony happy. Very happy.
mitchf
To clarify your second point, the FacebookMiddleware adds the facebook user data to the request, so you can get the user's profile information like so: fbuser = request.facebook.graph.get_object("me"). Then you can get data like the user's first name: fbuser['first_name'], gender: fbuser['gender'] or city/state: fbuser['location']['name']
mitchf
To post from Django to Facebook: request.facebook.graph.put_object("me", "feed", message="A post from Django!")
mitchf
@mitchf: Like you say. I wasn't sure which code is the original one and which is written by me, so I didn't mention those details
Tomasz Zielinski
it feels so good to find a bit of information about how to implement socialregistration: my question is now: how do you implement a user-info page :http://stackoverflow.com/questions/3978829/socialregistration-how-to-make-a-user-info-page-that-works-for-both-facebook-and
Mermoz
+2  A: 

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.

mitchf
+1  A: 

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

mitchf