Does facebook Like Button return any value (PHP)?

2020-07-25 01:43发布

问题:

I want to execute another function after user like my webpage.

Does facebook Like Button return any value like true or false. So I can perform any operation after ?

Or is there another alternative ??

回答1:

You'll have to use the Javascript API to do this:

FB.Event.subscribe('edge.create',
    function(response) {
        console.log("Here is the response %o", response);
    }
);


回答2:

AFAIK, "FB Like" is JavaScript addon (not PHP), but you could bind JS event to like button, that would send some AJAX data to your server, notifying it, about usage of Like button. Even thou, I'm not sure about my answer.



回答3:

You can subscribe to events edge.create and edge.remove they are used for tracking the firing of liking and unliking events respectively..

as a simple check add alert() in the response function to see if you got it right..

   FB.Event.subscribe('edge.create', function(response) {
    // A user liked the item, read the response and handle
    alert("like event detected");
  });

 FB.Event.subscribe('edge.remove', function(response) {
    // A user liked the item, read the response and handle
    alert("unlike event detected");

  });