How to check if facebook button has been clicked?

I put facebook as buttons on my Wordpress blog ... the idea is to use them as a kind of voting mechanism for posts. What I would like to do automatically adds a comment to the blog post every time someone “likes” it using the facebook button.

So my question is: does a similar api button provide some kind of callback to my page if someone “likes” something? - i.e. they didn’t like it yet, and they go through the process of sending it to facebook successfully.

Thanks for any help. Fyi I am very new to facebook api

- rich

+3
source share
3

edge.create docs:

FB.Event.subscribe('edge.create', function(href, widget) {
   alert('You just liked '+href);
});

- , ...

+4

, . , , ( ) php . - , .

. jquery ajax.

-------------------------------------------
  window.fbAsyncInit = function() {

    FB.init({appId: 'xxxxxxxxxxxxxxxxxx', status: true, cookie: true,
             xfbml: true});

B.Event.subscribe('edge.create', function(href, widget) {

$(document).ready(function() { 

var h_fbl=href.split("/");

var fbl_id=h_fbl[4]; 


 $.post("http://mypage.com/like.php",{ idfb:fbl_id,rand:Math.random() } )

}) });
  };
+1

, facebook-api:

JavaScript ():

FB.api({ method: 'pages.isFan', page_id: 'YOUR-PAGE-ID' }, function(resp) {
    if (resp) {
      alert('You like the Application.');
    } else {
      alert('You don't like the Application.');
    }
 });

PHP ( ):

$facebook = new Facebook(array(
    'appId' => 'YOUR-APP-ID',
    'secret' => 'YOUR-APP-SECRET-KEY',
));
$facebook->api(array(
                'method' => 'pages.isFan',
                'page_id' => 'YOUR-PAGE-KEY'
            ))

: http://forum.developers.facebook.net/viewtopic.php?id=101406

. Facebook. http://developers.facebook.com/docs/reference/rest/pages.isFan/

Remember that the REST-API (used in these examples) will be deprecated soon.

If you do not know where to get the SDK, you can take a look at this page: http://developers.facebook.com/docs/sdks/

+1
source

Source: https://habr.com/ru/post/1750826/


All Articles