Laj*_*pad 5 javascript facebook
我使用此代码来准备FaceBook API的用法:
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
Run Code Online (Sandbox Code Playgroud)
但是,在文档加载时我得到以下错误:
FB.getLoginStatus() called before calling FB.init().
Run Code Online (Sandbox Code Playgroud)
我不明白这个消息.我已经搜索了这个问题并发现了一些论坛帖子,但不幸的是它们根本没用.我已经决定在这里发布一个关于这个问题的问题,因为我无法解决它,因为我是关于Facebook API的noob.对不起,如果我的问题对任何人都太简单了,请提前感谢任何答案.
我有相同的Facebook日志
***FB.getLoginStatus() called before calling FB.init().***
Run Code Online (Sandbox Code Playgroud)
当文件加载时.我发现了#xfbml=1最后的结果
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
Run Code Online (Sandbox Code Playgroud)
犯这个错误.删除后#xfbml=1,没关系!
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: MS.FBAppID, // App ID from the App Dashboard
//channelUrl: '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
status: true, // check the login status upon init?
cookie: true, // set sessions cookies to allow your server to access the session?
xfbml: true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function (d, debug) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
} (document, /*debug*/false));
Run Code Online (Sandbox Code Playgroud)
我必须使用为此应用程序创建的 Facebook AppID 作为 AppID,并且必须确保域定义正确。
| 归档时间: |
|
| 查看次数: |
8239 次 |
| 最近记录: |