0

我正在使用PhoneGap-Facebook-plugin,它运行良好,我可以毫无问题地登录并访问令牌。但是当我更改html页面(window.location = 'page.html';)时,然后我调用FB.getLoginStatus(...)的响应是用户未连接。

我该如何解决这个问题?

FB.init()每次进入新的 html 页面时,我还必须再次执行此操作,否则会引发错误:FB.getLoginStatus() called before FB.init()

4

1 回答 1

1

一种解决方法是使用本地/会话存储

FB.getLoginStatus(function(response) {
     if (response.status === 'connected') {
         window.sessionStorage.setItem("FBUserAuth", JSON.stringify(response.authResponse));
     // do your stuff
     });

存储用户身份验证数据并在您的后续页面中使用 ajax 访问 Facebook 图形 API。

于 2013-06-16T02:08:15.427 回答