【发布时间】:2012-04-03 00:47:05
【问题描述】:
我正在开发一个 Facebook 页面选项卡应用程序,用户将在其中使用 HTML5 画布在页面上绘图。当用户提交他们的绘图(基本上是一个表单)时,我需要检查用户是否已授予我的应用程序必要的权限。如果没有,弹出 Facebook 对话框,要求用户在提交表单之前通过我的应用程序进行身份验证。一旦用户通过身份验证(或者如果他们已经通过身份验证),请提交表单。
简而言之,如果用户使用 Facebook Javascript SDK 对我的应用进行了身份验证,我如何才能提交表单?
更新:
根据 Shaun 的建议,我能够使用 FB.getLoginStatus 和 FB.Login 解决这个问题。这是一个例子:
$('#submit').on('click', function() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// User authenticated, submit the form
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
FB.login(function(response) {
// handle the response
}, {scope: 'email,'});
} else {
// the user isn't logged in to Facebook.
FB.login(function(response) {
// handle the response
}, {scope: 'email,'});
}
});
});
【问题讨论】:
标签: facebook facebook-javascript-sdk