Search code examples
facebookfacebook-likefacebook-sharer

Facebook Like notifications?


I saw a website today that stated: "Share/Like this site and get 10% discount". I was wondering: is there any way to track when someone shares/likes my site? Can I store some data of that user in my app?

I know those events have some callbacks, and maybe I can trigger some jQuery magic to send some data vía ajax when the user clicks on the button.

Any ideas?

Thanks!


Solution

  • Similar question was discussed here

    FB.Event.subscribe('edge.create', function(href) 
        {
    
        });
    

    From the above code you can get only href not any User details. So I tired the following code

    FB.Event.subscribe('edge.create', function (href) {             
                FB.login(function (response) {
                  if (response.session) {
                    //session object has uid & access token.
                  }
                });
    
              });
    

    The Problem you will have from above code is: Since FB.login will open a pop up window for log in, some browsers will block the pop up or warns the user. I tried the above code. LIKE functionality works and is posted to user's wall, but regarding getting user info: Firefox (4.0) - did not warn but it asked the user to authorize APP and access basic information. IE 9 - Gave a warning message about POP UP. Google Chrome : Blocked the log in pop up.
    It seems the only way to achieve this is let the user login to website using Facebook Connect first and then get user info using

     FB.Event.subscribe('edge.create', function (href) {
                // href is the URL of the object that got liked
                var x;
                FB.getLoginStatus(function (response) {
                  alert(response);
                  if (response.session) {
    
                  }
                });