views:

301

answers:

3

We have a social site, and want to integrate facebook connect to save time on the user needing to select their gender, etc. etc. and also use FB Connect as a method to skip signing up with us.

Each user on our site has a unique user name that they go by... One thing I can't wrap my head around, is if someone logs in with Facebook connect, how do I assign them a username? I mean, what if they dont want to user their real name? (assuming I would use their firstnameLastname, and add a number behind it if it existed already.. i.e: johnsmith, or johnsmith1, etc)

Perhaps I am confused, or am missing something... So how do I generate a user name?

I have the facebook connect button working, and it pops up with a slew of friends id's when they login...

so is there any good NON-facebook-made code samples? The runner app they have is a mess...

+1  A: 

See Facebook Connect documentation, esp How To Write A Good Connect App and Linking Accounts and Finding Friends.

Facebook Connect, as I understand it, is like OpenID used by stackoverflow. The linking is done using hash of email address, but for your application's user name, you could pick whatever you want. You can mimic what stackoverflow does, and set it temporarily as "unknown (Facebook)" until the user picks a unique user name. The user can continue to log back into your site using Connect, so she can stay "unknown (Facebook)" forever, which some people do on this site too.

eed3si9n
Perfect, thanks ;)
Mike Curry
A: 

It seems the problem you have is that this username you want to generate has to be unique in your system. Following Mike's idea would work if you do also what stackoverflow does and not have unique usernames, but "display names" which have some random string prefixing them. e.g. /users/xxxxxx/username

If you're looking for something more like twitter, where usernames are unique and no one can have the same one then you're going to have to prompt the user during the Facebook Connect process and ask the user to choose a username.

Eric Ferraiuolo
A: 

I think you can use the email address recieved from Facebook ;)

Tomáš Fejfar