Ton*_*bet 2 javascript jquery facebook
我试图检查用户是否登录Facebook(并重定向到其他页面),但我无法打开任何弹出窗口:
这将工作:但如果用户未登录Facebook,将打开弹出窗口
FB.login(function(response) {
if(response.status == 'connected')
/*Redirect here*/
});
Run Code Online (Sandbox Code Playgroud)
这是我的另一个网络,但不是在这里
window.fbAsyncInit = function() {
FB.init({
appId : myAppid, // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.login', function() {
/* REDIRECT HERE */
});
};
// Load the SDK Asynchronously
(function(d){
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/es_ES/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
Run Code Online (Sandbox Code Playgroud)
这有什么线索吗?
您可以使用FB.getLoginStatus
获取所需的信息.
在当前浏览器会话中第一次
FB.getLoginStatus
调用,或者JS SDK是初始化的status: true
,响应对象将由SDK缓存.后续调用FB.getLoginStatus
将从此缓存响应中返回数据.
文档示例:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7041 次 |
最近记录: |