简体   繁体   English

Facebook合并注册c#/ MVC3

[英]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. 我正在建立一个网站,我希望自己的用户数据库能够与Facebook个人资料“连接”/合并。

That means, both users with and without facebook is allowed. 这意味着,允许使用和不使用facebook的用户。 But I cannot for the life of me, figure out, how I join existing users in my database with facebook profile? 但我不能为我的生活,弄清楚,我如何加入我的数据库中的现有用户与Facebook个人资料?

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. 我已经在developers.facebook上看到了流程图,这正是我需要的,但我无法弄清楚要做什么来合并。 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/ 我在这里读了很多: 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. 当人们通过Facebook注册时,他们正在做两件事 - 他们正在连接到您的Facebook应用程序(您创建的用于获取应用程序ID和应用程序秘密的应用程序),并且他们正在您的网站上注册。

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. 如果他们已经在您的网站上注册但没有通过Facebook连接,那么Facebook就没有任何方式可以知道这一点,所以您可以通过它来解决问题。 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. 也许他们已经正常登录,所以你有他们的用户ID或类似内部的东西。 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. 您如何创建他们的帐户或添加您刚刚从Facebook获得的任何额外数据取决于您。

To get the data you'll have to process the signed_request POST variable which will have all the data on it. 要获取数据,您必须处理signed_request POST变量,该变量将包含所有数据。 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. 请记住,Facebook正在为您提供更容易的数据收集,因为它可以为您输入名称,电子邮件,生日等内容,因此用户无需全部输入。您仍然可以创建用户并执行任何操作在你的最后。

Connecting through Facebook will connect them with your app but you'll still need to create an account for them. 通过Facebook连接将他们与您的应用程序连接,但您仍然需要为他们创建一个帐户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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