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

后端 未结 6 936
北恋
北恋 2020-12-08 04:18

I\'ve this message in my console

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

My code



        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 04:47

    Short answer

    Add &status=0 to your js.src URL to make the warning disappear, ie:

    //connect.facebook.net/fr_FR/all.js#xfbml=1&status=0

    Full answer

    FB.init() will be called internally by the facebook script upon loading if parameters are provided after the hash (#) sign. Here xfbml is passed, so FB.init() is called.

    (source code: http://connect.facebook.net/fr_CA/all/debug.js line 8699 at the time of this post)

    The default args for init() are used if not explicitly provided: status arg default is true - which makes the FB script call getLoginStatus() at startup, which complains because an app ID is needed for that function call.

    FB social plugins doesn't need an app ID - they are rendered into an iframe originating from facebook.com, so FB login status and cookies as accessible to them.

    The "Get the Code" wizards in the FB developers Social Plug-ins section generates a URL with the xfbml param, it should be updated with the status=0 param IMHO.

提交回复
热议问题