У меня была установкаКак огонь событие, когда пользователь вошел в с Facebook
<div id="fb-root"></div><div class="fb-login-button" data-show-faces="true" data-width="400" data-max-rows="1" scope="email, publish_stream"></div><script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: 'xxx', // App ID
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true, // parse XFBML,
oauth : true
});
FB.Event.subscribe('auth.authResponseChange', 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;
// TODO: Handle the access token
$.post('/facebook/login', { accessToken: accessToken }, function (response) { if(response) {alert('Logged in')} });
} 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.
}
});
};
// 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));
Проблема заключается в том, когда пользователь нажимает на кнопку Login и Accept мое приложение, окно Логин закрыт и ни одно событие не является так что мой пост $ .post ('/ facebook/login') также не срабатывает, если я не нажму F5.
Как я могу запустить событие сразу после закрытия диалогового окна входа в систему?
Первый фрагмент кода вызывает бесконечный цикл. – holyredbeard
@holyredbeard это старый ответ (май 2012), и Facebook сделал много изменений все эти месяцы. Я думаю, что голосование по старому голосованию - это не лучшее, что вы можете сделать! Почему вы не открываете новый вопрос для своей проблемы? – Philip
@holyredbeard Посмотрите сюда, чтобы узнать больше о FB.Login(): http://developers.facebook.com/docs/reference/javascript/FB.login/ – Philip