我正在为Facebook开发一个应用程序。自动调用FB.init()后的FB.login()
我的代码:
function init() {
window.fbAsyncInit = function() {
var appID = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
FB.init({ appId: appID,
status: true,
cookie: true,
xfbml: true});
login();
};
(function() {
var e = document.createElement("script");
e.async = true;
e.src = "https://connect.facebook.net/en_US/all.js?xfbml=1";
document.getElementById("fb-root").appendChild(e);
}());
};
function login() {
FB.login(function(response) {
if (response.session) {
if (response.perms) {
// user is logged in and granted some permissions.
// perms is a comma separated list of granted permissions
} else {
// user is logged in, but did not grant any permissions
}
} else {
// user is not logged in
}
}, {perms:'read_stream,publish_stream,offline_access'});
};
我想自动调用“初始化”功能,并经过“初始化”应该叫“登录”功能(打开Facebook的登录窗口)。
但我总是得到“b is null” FB.provide('',{ui:function(f,b){if(!f....onent(FB.UIServer._resultToken));}});
Firebug中的错误。
任何人都可以帮助我吗? 有没有人有同样的问题?
感谢
你什么时候调用init()? – Abby
我在我的HTML页面上有一个Button“Start Facebook”。这个按钮调用了“init”函数。当我使用2个按钮(一个调用init,另一个调用登录),一切都很好,但我只想要一个按钮。 –