Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FB.Event.subscribe & FB.getLoginStatus not firing

I've looked through various documentations and questions here on stackoverflow and still can't figure out why the following code will not fire any of the FB.Event.subscribe events getLoginStatus.

<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> 
like image 710
mistyayn Avatar asked Dec 06 '25 13:12

mistyayn


1 Answers

In case anyone else needs it I found the answer to my question on this other question:

FB.Event.subscribe not working for auth.login, auth.logout and auth.statusChange

I went into facebook and updated the Canvas URL to my localhost URL and it worked.

like image 62
mistyayn Avatar answered Dec 10 '25 15:12

mistyayn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!