Like FB page doesn't fire edge.create event after confirming

Viewed 1160

The following codes have worked before but not now. Since FB added the confirm box when liking a page, the edge.create was no more fired after confirming.

    <div class="fb-page" data-href="{{ $fbPageUrl }}" data-tabs="timeline" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true"></div>
    <script>
        $(document).ready(function() {
            $.getScript('//connect.facebook.net/en_US/sdk.js', function(){
                FB.init({
                    appId      : 'xxxxxxxxxxxxxx',
                    xfbml      : true,
                    version    : 'v2.9'
                });

                FB.Event.subscribe('edge.create', function(response) {
                    alert('Fired!');
                });
            });
        });
    </script>
4 Answers

I suspect this is a bug from the new Facebook's update. You can search for the issue here https://developers.facebook.com/bugs, also can post a new bug if it hasn't been reported yet

These Events will no longer be accessible. As an alternative, you can use our Webhooks and be notified every time someone likes one of your Facebook Pages.

This is the webhooks endpoint

Source

Working solution until now:

<!doctype html>
<html lang="en" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
    <meta charset="utf-8">
    <title>Facebook Like Button</title>
</head>
<body>
<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function () {
        FB.init({appId: '1906177386133148', status: true, cookie: true, xfbml: true});
        FB.Event.subscribe("edge.create", function (targetUrl) {
            console.log('edge.create');
        });
        FB.Event.subscribe("edge.remove", function (targetUrl) {
            console.log('edge.remove');
        });
    };
    (function () {
        var e = document.createElement('script');
        e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/es_ES/all.js';
        document.getElementById('fb-root').appendChild(e);
    }());
</script>
<fb:like></fb:like>
</body>
</html>
Related