开发者

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 开发者_如何学Goon a userid lookup from the Facebook response.

I have a couple of questions surrounding this:

  • Presumeably I can do all of this using the Facebook API - without the need for an actual pretty public facing 'application' on Facebook? I simply want to utilise the Facebook API for authenticating an account. I'm not interested in creating some app for doing something 'within' facebook itself.

  • I have located some code snippets online and tried using the Facebook Developer Toolkit, calling the getInfo method, and whilst it does come back to my website with a uid, none of the other user information is present within the response, like Email, Name etc. The uid is the only populated field in the response.

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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜