Facebook like callback, and post it to target to like

梦想与她 提交于 2019-12-19 04:44:13

问题


when i'm looking at the html source, i look this javascript code

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script >
FB.init({
    status: true,
    cookie: true,
    xfbml: true
});
var username= "gun";

var timenow="1311002200";
var securitykey="ef64ba59d2b0f26d69c94fafb3f008e0";
//pls find a way to capture username either session or something else.
FB.Event.subscribe('edge.create', function(response) {
    document.getElementById(response).style.visibility = "hidden";
     document.getElementById(response+'1').style.visibility = "visible";
  //response will be   



    $.ajax({
        type: "POST",
        url: "fbreceive.php",
        data: "data="+response + "---" + username+ "---"+securitykey+ "---"+timenow,

        //this will post to fb receive as url=http://facebookpagewhichwasliked&user=username
        cache: false
    });

});


</script>

can you tell me the fbreceive.php contains what (somekind of facebook api) ? because without that, the url we did to like is unlike again automatically...


回答1:


FB.Event.subscribe('edge.create', function(){...}) is a callback triggered when the Facebook like button is clicked. The ajax call to fbreceive.php is keeping a track of which logged in user is "liking" which content on the site and when (the comments are also quite explanatory). The username and timenow have been captured from the user's session and included as a part of the javascript.

It's a really neat idea, I would say!



来源:https://stackoverflow.com/questions/6735609/facebook-like-callback-and-post-it-to-target-to-like

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!