getLoginStatus不触发从FB画布调用 [英] getLoginStatus not firing with calling from FB canvas

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

问题描述

尝试客户端站点授权,并尝试在画布中运行。如果我直接访问我的网站, http://mysite.com/ 一切正常。如果我尝试通过画布运行 https://apps.facebook.com/myapp 它运行,但getLoginStatus

Attempting a client site authorization, and attempting to run within a canvas. If I access the my website directly http://mysite.com/ everything works. If I try to run via canvas https://apps.facebook.com/myapp it runs but getLoginStatus does not fire at all.

var curLoc = window.location;


 FB.init({
   appId: 'xxxxxxxxxxxxxxx', // App ID
   channelUrl: curLoc.protocol + "//" + curLoc.hostname + ":" + curLoc.port + "/channel.html",
   cookie: true, // enable cookies to allow the server to access the session
   status: true,
   oauth: true,
   xfbml: true
 });

 FB.getLoginStatus(function (response) {
   if (response.status === 'connected') {
     smloader.gameVariables.smUserid = response.authResponse.userID;
     facebook.isLoaded = true;
   } else {
     facebook.authUser();
   }

 }, true);

需要时登录。

function facebook.authUser() {
 FB.login(function (response) {
   if (response.authResponse) {
     smloader.gameVariables.smUserid = response.authResponse.userID;
     facebook.isLoaded = true;
   }
   else {
     facebook.authUser();
   }
 }, { scope: 'email,publish_actions' });

}

Facebook.isLoaded真的,我知道我们已经登录并准备继续。但它从来没有直接从画布页。

Once Facebook.isLoaded is true, I know we are logged in and ready to continue. but it never gets there directly from the canvas page.

我在沙盒模式,目前正在通过http而不是https,因为我不

I am in sandbox mode, currently running via http not https as I don't

任何想法?

推荐答案

我一直面对同样的pb,这是我如何修复它:

I have been facing the same pb and this is how i fixed it :

即使getLoginStatus()在您的http网站中工作,除非您提供有效的安全画布网址 https://yoursite.com/ )!
这意味着您需要在https服务器(端口443)上运行应用程序

如果您不想购买证书,可以创建并自行签署证书(请参阅: a href =http://greengeckodesign.com/blog/2013/06/15/creating-an-ssl-certificate-for-node-dot-js/ =nofollow> http://greengeckodesign.com / blog / 2013/06/15 / creating-an-ssl-certificate-for-node-dot-js / )

Even if the getLoginStatus() works within your http website, the getLoginStatus() will not fire at all within the fb canvas unless you provide a valid Secure Canvas URL (https://yoursite.com/) ! It means you need to run your app on a https server (port 443)
If you do not want to buy a certificate you can create and self-signed a certificate (see here : http://greengeckodesign.com/blog/2013/06/15/creating-an-ssl-certificate-for-node-dot-js/)

这篇关于getLoginStatus不触发从FB画布调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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