0

是否可以将 Facebook 的postLike 函数包含到下面的 jquery 代码中以处理按钮单击或提交

function postLike(){FB.api("/me/og.likes","post",{object:"http://test.com/test"})}

$(".bookmark_form").live("submit",function(a){a.preventDefault();$.post("/",
$(this).serialize(),function(){$("#buddy").html(" ");
$.ajax({url:$("#buddy").attr("rel"),
dataType:"html",success:function(c){$("#buddy").html(c)}});return false})});

先感谢您!

4

1 回答 1

1

是的,很有可能。

包括 JS SDK。包括 jQuery。

$(document).ready(function(){

$("#id of button").click(function(){
   FB.api('/me/og.likes',{object:'URL OF YOUR OPEN GRAPH OBJECT'}, function(response){
    if(response){
       alert(Success! It was liked!");
    }else{
       alert("Failure! Something went wrong.");
    }
  });
});

});

您的 OPEN Graph OBJECT 的 URL上,您必须通过Open Graph Protocol实现一个对象

于 2013-03-19T20:01:58.077 回答