在调用FB.init()之前调用FB.getLoginStatus()。在phonegap

时间:2013-08-16 21:24:47

标签: jquery cordova facebook-javascript-sdk

我正在尝试使用FB.api

在phonegap中获取facebook_friendsList

我认为问题是在app创建fb.init函数之前调用的函数

这是我的代码:

<script>
      // Initialize the Facebook SDK


      document.addEventListener('deviceready', function() {
          FB.init({
              appId: '427370550688587',
              nativeInterface: CDV.FB,
              useCachedDialogs: false
          });

          FB.getLoginStatus(handleStatusChange);


          authUser();
          updateAuthElements();


      });

      FB.api('/me/friends', function(response) {
        if(response.data) {
            var flist;
            $.each(response.data,function(index,friend) {
                alert(friend.name + ' has id:' + friend.id);
            });
        } else {
            alert("Error!");
        }
    });


        //Fetch user's id, name, and picture


  </script>

它是警报错误并且在consol中出现此错误

FB.getLoginStatus() called before calling FB.init().

...

1 个答案:

答案 0 :(得分:0)

跟踪我打开的帖子: How to tell when FB.init() completed? How to tell if the user is not connected when to app starts?

我问如何判断fb.init()何时完成..所以,如果有人愿意我的话,它也会解决你的问题