Automatically invoking FB.login on Facebook page tab app for non-logged in user

南笙酒味 提交于 2019-12-11 03:54:09

问题


I have a Facebook Page tab app. For a user who is not logged in, I want to:

  • Detect if user is not logged in
  • If not logged in, automatically direct user to login

My current approach is to use FB Javascript SDK (in preference to server-side authentication flow):

  • On page load, run FB.getLoginStatus to check user status
  • If user is not logged in, run FB.login to invoke OAuth dialog

Problem:

  • FB.login creates a pop-up dialog (prefer if within Page Tab iframe)
  • This pop-up dialog is blocked if FB.login is not invoked from a button (I would really like to avoid having the user click a button; so would really like to invoke it automatically, when I find a user that is not logged in)

回答1:


I would really like to avoid having the user click a button

FB.login without user interaction -> blocked popup

prefer if within Page Tab iframe

The Auth dialog won’t work inside an iframe, it’s designed that way.

If the automatic call of the login dialog is your most important requirement – then use JavaScript to redirect to the Auth dialog URL, and redirect back to your page/app Facebook address afterwards. See section “Client-side authentication without the JS SDK” here: https://developers.facebook.com/docs/authentication/client-side/



来源:https://stackoverflow.com/questions/11972450/automatically-invoking-fb-login-on-facebook-page-tab-app-for-non-logged-in-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!