Facebook Connect 用于简单身份验证?
我有一个 ASP.net 网站,我想在其中引入“Facebook Connect”功能,纯粹用于帐户登录/创建目的。我希望用户能够单击“使用 Facebook 登录”类型按钮,然后根据 Facebook 响应中的用户 ID 查找将该用户登录到我的网站。
我对此有几个问题:
大概我可以使用 Facebook API 完成所有这些工作 - 而不需要 Facebook 上真正面向公众的“应用程序”?我只是想利用 Facebook API 来验证帐户。我对创建一些应用程序来在 facebook 本身“内部”执行某些操作不感兴趣。
我在网上找到了一些代码片段,并尝试使用 Facebook Developer Toolkit,调用 getInfo 方法,虽然它确实带着 uid 返回到我的网站,但响应中不存在其他用户信息,例如电子邮件、名称等。uid 是响应中唯一填充的字段。
这是我使用的代码:
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;
}
任何人都可以帮助解决这两个查询吗?
提前致谢...
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:
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Starnzy,已经有一个 StackOverflow 线程讨论此问题,得到了一些很好的回应。经过一些调整,添加函数调用应该可以在您的代码中工作。
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.