Javascript 错误:在调用 FB.init() 之前调用了 FB.login()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4910974/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: FB.login() called before calling FB.init()
提问by Genadinik
I use this Facebook Login Button code:
我使用这个 Facebook 登录按钮代码:
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'myActualId',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
<fb:login-button show-faces="false" width="200" max-rows="1"></fb:login-button>
But the debug console gives me this error: FB.login() called before calling FB.init().
但是调试控制台给了我这个错误:在调用 FB.init() 之前调用了 FB.login()。
I made a test page so my error can be seen: http://www.comehike.com/test_fb_connect.php
我做了一个测试页面,所以可以看到我的错误:http: //www.comehike.com/test_fb_connect.php
I have no idea what I am doing wrong. Any help would be much appreciated!
我不知道我做错了什么。任何帮助将非常感激!
Thanks, Alex
谢谢,亚历克斯
回答by Mohammad Arif
If you pass the non existing FB app key to init() then only you get the error of 'FB.login() called before calling FB.init()'
如果您将不存在的 FB 应用程序密钥传递给 init(),那么您只会收到“在调用 FB.init() 之前调用 FB.login()”的错误
Make sure, you hadn't been doing the same.
确定,你没有做同样的事情。
回答by John Pick
You're loading the Facebook script all.js twice. It should be loaded only once.
您正在加载 Facebook 脚本 all.js 两次。它应该只加载一次。
回答by Genadinik
Seeing as no one on the interwebs was able to answer my question, I wiped out the old Facebook app entirely (on my developers.facebook.com account) and just made a new app from scratch and made a totally new one.
看到互联网上没有人能够回答我的问题,我完全删除了旧的 Facebook 应用程序(在我的开发者.facebook.com 帐户上),并从头开始制作了一个新应用程序并制作了一个全新的应用程序。
After that, the basic code did the job
之后,基本代码完成了这项工作
回答by Leroy
This worked for me
这对我有用
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
appId : true,
status : false, // check login status
cookie : false, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>