我正在考虑记录使用 FB 进入网站的所有用户。在 purushotam 的帮助下(请参阅我的其他问题)能够继续。
这是我的新问题: 1)我如何获取/使用facebook提供的按钮。原因是我希望用户获得相同的用户体验。 (facebook按钮蓝色按钮) 2)一旦用户登录,我想发送警报并转到我重定向的网站(例如我有 stackoverflow)。因为 FB 是非阻塞异步的,所以我在 FB 返回值之前看到网站正在重定向。如何解决这个问题。 3)当用户尝试登录时,我不希望 FB 弹出窗口 - 我想在新页面中登录 FB(就像 stackoverflow 登录一样)我该怎么做..
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'xxxx', status: true, cookie: true, xfbml: true});
};
(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);
}());
function fetchUserDetail()
{
FB.api('/me', function(response) {
alert("Name: "+ response.name + "\nFirst name: "+ response.first_name + "ID: "+response.id);
});
window.location.href = 'http://www.stackoverflow.com';
}
function checkFacebookLogin()
{
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
fetchUserDetail();
}
else
{
initiateFBLogin();
}
});
}
function initiateFBLogin()
{
FB.login(function(response) {
fetchUserDetail();
});
}
</script>
<input type="button" value="Sign in using Facebook" onclick="checkFacebookLogin();"/>
</body>
最佳答案
1) how can I get/use the facebook provided button. Reason is I want user to get the same user experience. (facebook button bluish button)
https://developers.facebook.com/docs/reference/plugins/login/ , https://www.facebook.com/brandpermissions/logos.php
2) once the user logs in than , I want to send a alert and than go to the website I re-directed (in example I have stackoverflow). Because FB is non blocking asynchronous, I see before the FB returns the value the website is getting redirected. how to resolve this issue.
抱歉,我不太明白你在问什么。请尝试更具体。
3) When a user tries to login I dont want the FB popup- I want to have the FB login in a new page (just like stackoverflow login) how can I do that ..
那就不要使用 FB.login,而是将用户重定向到 Auth 对话框的 URL;请参阅https://developers.facebook.com/docs/authentication/client-side/#no-jssdk
关于javascript - Facebook API 登录 - 日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11840555/