如果用户在oauth流程中关闭或点击Facebook权限窗口上的取消按钮,我是否想通知父页面。它是用户授权应用程序的窗口。带有网址的窗口: www.facebook/dialog/oauth?api_key= .....和使用Facebook登录和取消按钮。我想要完成的是 - 如果用户取消或关闭oauth权限窗口,我想打开Facebook简单的共享窗口,在那里他们可以发布状态,而不授权应用程序。
I am trying to figure if there is any way to notify the parent page when user either closes or clicks on cancel button on Facebook permissions window during oauth flow. Its the window where user authorizes an app. The window with url: www.facebook/dialog/oauth?api_key=..... and with "Login with Facebook" and "Cancel" buttons. What I am trying to accomplish is-- If user cancels or closes the oauth permissions window, I would like to open Facebook simple sharing window where they can post status without authorizing the app.
我正在使用JS SDK进行Facebook连接。
I am using JS SDK for Facebook connect.
推荐答案代码取自 FB.login方法的文档:
FB.login(function(response) { if (response.authResponse) { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Good to see you, ' + response.name + '.'); }); } else { console.log('User cancelled login or did not fully authorize.'); } });如您所见, if(response.authResponse)部分检查,而不是登录过程成功完成,即用户允许应用程序,并且他已经登录到Facebook。
As you can see, the if (response.authResponse) part checks rather the login process was finished successfully, that is, the user allowed the application and he is logged in to facebook.
如果用户点击取消或关闭弹出窗口,那么响应中就不会有 authResponse 参数。
If the user clicked "cancel" or closed the popup then there won't a authResponse parameter in the response.
更多推荐
如何检测Facebook oauth窗口关闭的操作从用户
发布评论