Fb.event.subscribe & fb.getloginstatus не стреляет
-
12-12-2019 - |
Вопрос
Я просматривал различные документы и вопросы здесь на Stackoverflow и до сих пор не могу понять, почему следующий код не будет уволить любой из событий FB.Event.subscribe.
<div id="fb-root">
<script>
(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));
window.fbAsyncInit = function () {
FB.init({
appId: '{appID}', // App ID
channelUrl: '{channelURL}', // Channel File
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true, // parse XFBML
oauth: true // enable OAuth 2.0
});
FB.Event.subscribe('auth.authResponseChange', function (response) {
console.log(response);
});
FB.Event.subscribe('auth.login', function (response) {
console.log(response);
});
FB.Event.subscribe('auth.statusChange', function (response) {
console.log(response);
});
FB.getLoginStatus(function (response) {
console.log(response);
});
};
</script>
</div>
<div>
<div class="fb-login-button" data-show-faces="true" data-width="400" data-max-rows="1"></div>
</div>
. Решение
Если кому-то еще нуждается в этом, я нашел ответ на мой вопрос на этом другом вопросе:
fb.event. Подписаться не работает на auth.login, auth.logout и auth.statuschange
Я пошел в Facebook и обновил URL-адрес Canvas моему localhost URL и работал.
Не связан с StackOverflow