Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling a click on Facebook's "Subscribe" button

How can I fire an event when someone presses the NEW Facebook Subscribe button? I can do that with the "Like" button, using the code above, so I thought that it will be similar with the Subscribe button.

<div id="fb-root"></div>
<script type="text/javascript">
    window.fbAsyncInit = function() {
    FB.init({appId: 'App_ID', status: true, cookie: true, xfbml: true});
        FB.Event.subscribe('edge.create', function(href, widget) {
            alert('You just clicked the like button');
        });
    };

    (function() {
        var e = document.createElement('script');
            e.type = 'text/javascript';
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
    }());
    </script>

The 'edge.create' fires an event when the user likes a page, so I can get the response, and show the alert to the user. I've searched for a while, and couldn't find a way to a similar thing with the "Subscribe" button.

Has anyone done that?

like image 905
Diego Gadens Avatar asked May 01 '12 20:05

Diego Gadens


1 Answers

Unfortunately, Niraj's answer is incorrect. There are functions in the FB API that handle detecting events like you describe, but there is nothing that can detect if a user is subscribed as of now. You can detect if a user like, unlikes, comments, etc. but not if a user subscribes.

like image 150
Skyler McCoy Avatar answered Oct 09 '22 01:10

Skyler McCoy