1
你好,我正在使用這個功能來登錄Facebook。現在瀏覽器禁止彈出窗口打開並請求許可。如何解決它?我可以忽略這個問題,就是瀏覽器將此視爲非用戶事件。Web瀏覽器可以防止Facebook彈出登錄窗口
function chk_login()
{
window.fbAsyncInit = function() {
FB.init({appId: my_app_id, status: true, cookie: true, xfbml: true,oauth : true});
FB.getLoginStatus(function(response) {
if (response.authResponse) {
var fb_access_token = response.authResponse.accessToken;
FB.api('/me', function(response) {
console.log(response);
});
}
else
{
}
});
FB.login(function(response) {
if (response.authResponse) {
var fb_access_token = response.authResponse.accessToken;
FB.api('/me', function(response) {
console.log(response);
});
}
},{scope: fb_scope});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
}
<img src="fb_login.jpeg" onclick="chk_login()" alt="Facebook Login" style="cursor:pointer;"/>
但是如果我不需要獲取用戶信息(`/ me`)***每次***頁面加載?現在在你編寫請求`FB.api('/ me'`在每一頁加載/重載的時候都做了,爲什麼?當用戶明確地點擊一個按鈕「Get User Data」時,我只需要調用這個函數。 – Green 2014-09-12 12:23:06