如何检测Facebook oauth窗口关闭的操作从用户

编程入门 行业动态 更新时间:2024-10-07 12:19:27
本文介绍了如何检测Facebook oauth窗口关闭的操作从用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果用户在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窗口关闭的操作从用户

本文发布于:2023-11-03 04:56:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554291.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗口   操作   用户   Facebook   oauth

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!