asp.netfacebookauthenticationfbconnect

Facebook Connect for simple authentication?


I have an ASP.net website which I want to introduce 'Facebook Connect' functionality into, purely for account login/creation purposes. I want a user to be able to click the 'Login using Facebook' type button, and to then log that user into my website based on a userid lookup from the Facebook response.

I have a couple of questions surrounding this:

Here is the code I use:

if (ConnectAuthentication.isConnected())
        {
            API api = new API();

            api.ApplicationKey = ConnectAuthentication.ApiKey;
            api.SessionKey = ConnectAuthentication.SessionKey;
            api.Secret = ConnectAuthentication.SecretKey;
            api.uid = ConnectAuthentication.UserID;

            //Display user data captured from the Facebook API.
            facebook.Schema.user facebookUser = null;
            try
            {
                facebookUser = api.users.getInfo();

                User user = new User();
                user.FacebookUser = facebookUser;
                user.IsFacebookUser = true;

                return user;

            }
            catch { return null; }
        }
        else
        {
            return null;
        }

Can anyone please help with either/both of these queries?

Thanks in advance...


Solution

  • Starnzy, there's already a StackOverflow thread on this, got some good responses. With some adjustments adding the function calls should work in your code.