如何检测Facebook oauth窗口关闭的操作从用户 [英] How to detect Facebook oauth window closed action from user

查看:164
本文介绍了如何检测Facebook oauth窗口关闭的操作从用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户在oauth流程中关闭或点击Facebook权限窗口上的取消按钮,我是否想通知父页面。它是用户授权应用程序的窗口。带有网址的窗口: https://www.facebook.com/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: https://www.facebook.com/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窗口关闭的操作从用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆