2012-10-19 24 views
4

嘗試客戶端站點授權,並嘗試在畫布內運行。如果我直接訪問我的網站http://mysite.com/一切正常。如果我嘗試通過畫布運行https://apps.facebook.com/myapp它會運行,但getLoginStatus根本不會啓動。getLoginStatus在FB canvas調用時未觸發

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是真的,我知道我們登錄並準備繼續。但它永遠不會從canvas頁面直接進入。

我在沙盒模式,當前通過HTTP沒有使用https運行,因爲我不

什麼想法?

+1

你曾經解決過這個問題嗎?我現在遇到同樣的問題 – Rondel

+0

您在控制檯中是否出現錯誤? FB.init應該在'window.fbAsyncInit = function(){FB.init(...);}' –

回答

1

我一直面臨着同樣的鉛,這是我如何固定它:

即使getLoginStatus()工作的HTTP網站內的getLoginStatus()將不會觸發在所有FB帆布除非內您提供了有效的安全畫布網址https://yoursite.com/)! 這意味着你需要在你的HTTPS服務器上的應用程序(端口443)
如果你不想買你可以創建一個證書和自簽名的證書(在這裏看到:http://greengeckodesign.com/blog/2013/06/15/creating-an-ssl-certificate-for-node-dot-js/

我希望這將有助於