[英]Facebook login using javascript sdk without popup
I'm using the javascript sdk to implement facebook login. 我正在使用javascript sdk来实现facebook登录。 Is it possible to redirect the user to the full login page instead of displaying the popup?
是否可以将用户重定向到完整的登录页面而不是显示弹出窗口? I tried adding display : 'page' but that doesn't seem to do anything.
我尝试添加display:'page',但似乎没有做任何事情。
FB.init({
appId: '123456789',
cookie: true,
status: true,
xfbml: true,
frictionlessRequests: true,
oauth: true
});
function login() { //this function called on click of login button
FB.login(function (response) {
//my code
}, { scope: 'email,publish_stream,read_stream,offline_access' });
});
Thanks 谢谢
login with facebook-javascript-sdk always opens up in popup atleast for me. 用facebook-javascript-sdk登录总是打开弹出窗口至少对我来说。 if you want to it to display in complete page instead of popup you should consider other options like server side authentication where setting the option
display:page
works. 如果你想让它显示在完整的页面而不是弹出窗口,你应该考虑其他选项,如服务器端身份验证,其中设置选项
display:page
工作。
One of the answers on this post worked for me: Facebook login without pop-up? 这篇文章的答案之一对我有用: Facebook登录没有弹出窗口?
Here is the code. 这是代码。 It should be run after
window.onload
它应该在
window.onload
之后运行
var APPID = "YOUR_APP_ID"
var uri = encodeURI('http://example.com');
FB.init({ appId: APP_ID,
status: true, // check login status
});
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//user is logged in
} else {
window.location = encodeURI("https://www.facebook.com/dialog/oauth?client_id=" + APPID + "&redirect_uri="+uri+"&response_type=token");
}
});
For complete-ness sake, here is the code that loads the FB JS SDK. 为了完整起见,这里是加载FB JS SDK的代码。
// 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/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.