Trigger facebook action "like" with js sdk

What is the correct syntax for triggering a "similar" action through FB js sdk? The custom action is as follows:

FB.api('/me/recipebox:cook', 'post', { recipe : 'http://www.example.com/pumpkinpie.html' }); 

According to: https://developers.facebook.com/docs/opengraph/actions/#create


Edit is what I ended up using:

  $("#testLink").click(function(){ $.post("https://graph.facebook.com/<?php echo $user_profile[id]; ?>/og.likes", { access_token: FB.getAuthResponse()['accessToken'], object: "http://www.matrym.com/fb/temp.php" }, function(data) { alert("Data Loaded: " + data); } ); }); 
+4
source share
1 answer

After the following conditions are met ...

An application can publish the built-in Like action, on behalf of the user, as if the following conditions are true:

  • The content viewer in the application is a Facebook user who has Facebook-authed and has granted permission to publish the application.
  • The content of the application has a page with objects of an open graph, which is correct using the Open Graph meta tags
  • The viewer deliberately clicked the โ€œlike buttonโ€ button in the application, associated with the content in the application.

you call the API like this:

 FB.api('/{object id}/likes', 'post'); 

Link: https://developers.facebook.com/docs/opengraph/actions/builtin/likes/

"Likes" must be pre-configured by webmasters, otherwise Facebook does not know what you really "love." Each of them has an object identifier associated with it. If this is your own website, you need to configure what your site may like (and the FB associates an ID with it), then you can send the name you like for this object.

+5
source

All Articles