不再可以从http页面调用FB.getLoginStatus方法 [英] The method FB.getLoginStatus can no longer be called from http pages

查看:247
本文介绍了不再可以从http页面调用FB.getLoginStatus方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我尝试在我的nodejs后端服务器中实现Facebook登录功能.出于测试目的,我正在尝试客户端检查登录名并获取访问令牌.为此,我遵循了文档,并说要使用Javascript SDK,并且遵循了该过程,但是存在问题.

So I tried to implement Facebook Login feature in my nodejs backend server. For testing purpose, I am trying client side to check the login and get access token. For that, I followed the docs and it says to use Javascript SDK and I followed the procedure, but there is a problem.

window.fbAsyncInit = function() {
    FB.init({
      appId            : '##############',
      autoLogAppEvents : true,
      xfbml            : true,
      version          : 'v4.0'
    })


    FB.getLoginStatus(function(response) {
        statusChangeCallback(response);
    });

  }

这是我要获取用户登录状态的代码,但是出现错误消息:

This is the code where I want to get the user login status, but I get an error saying:

The method FB.getLoginStatus can no longer be called from http pages

我非常了解生产规则,但这是我正在开发的开发模式,仍然出现错误.我有什么想念的吗?我有什么需要做的吗?我在本地主机上运行它并收到错误.

I am very much aware about the production rules, but this is development mode I am working on and still getting the error. Anything I am missing? Anything I have to do? I am running it on localhost and getting the error.

推荐答案

  • 如果您的服务器在本地主机上(也就是在您的计算机上)运行:在本地主机上对https使用 devcert
  • 或者,手动使用自签名证书
  • ...或如果要公开本地服务器,请使用 ngrok
  • 如果不在本地主机上,请通过certbot使用让我们加密的免费证书: https://letsencrypt.org/docs/client-options/
    • If your server runs on localhost (aka on your machine): Use devcert for https on localhost
    • alternatively, use a self signed certificate manually
    • ...or use ngrok, if you want to expose your local server
    • If not on localhost, use a free certificate of Let's Encrypt with certbot: https://letsencrypt.org/docs/client-options/
    • 这篇关于不再可以从http页面调用FB.getLoginStatus方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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