简体   繁体   中英

Facebook merge registration c#/MVC3

I can't believe I'm asking this, since it apparently should be very simple.

I'm building a website, where I'd like my own user database to be able to "connect"/merge with a facebook profile.

That means, both users with and without facebook is allowed. But I cannot for the life of me, figure out, how I join existing users in my database with facebook profile?

I've seen the flowchart on developers.facebook which is exactly what I need, but I can't figure out what to do to merge. What do I need to do in my database? and how do I capture the information I need from the registration plugin to merge?

I've read a lot here: http://developers.facebook.com/docs/plugins/registration/

But I can't see the connection.

When people register via Facebook they are doing 2 things - they are connecting to your Facebook App (the one you created to get an App Id and App Secret) and they are registering on your site.

If they have registered on your site but not connected via Facebook, Facebook doesn't have any way of knowing that so it falls on you to figure it out. They'll go through the registration process as if they were a new user, but when you get the data you should check and see if you have a user that matches already. How you do that is up to you. Maybe they were already logged in normally and so you have their user id or something internal like that. Maybe they weren't and you have to see if the email address used is already in the database. How you then create their account or add any extra data you just gained from Facebook is up to you.

To get the data you'll have to process the signed_request POST variable which will have all the data on it. This is when you look at the email address or whatever fields you want to use to determine if the user already exists or not.

You should also be creating the new user in your database at this time. How you do that is again up to you.

Remember, Facebook is making the collecting of data easier as it imports things like name, email, birthday, etc for you so users don't have to type it all in. It's still up to you to create the user and do whatever you do on your end.

Connecting through Facebook will connect them with your app but you'll still need to create an account for them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM