2011-07-18 32 views
1

當我在看html源代碼,我看這Facebook的像回調,並張貼到目標喜歡

<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> 

你能告訴我JavaScript代碼fbreceive.php包含的facebook是什麼(somekind的api)? 因爲沒有這個,我們確實喜歡的網址不再自動地...

回答

1

FB.Event.subscribe('edge.create',function(){...})是一個回調,當Facebook像按鈕被點擊。對fbreceive.php的ajax調用保持跟蹤哪個登錄用戶「喜歡」網站上的哪些內容以及什麼時候(評論也很有說服力)。用戶名和時間已從用戶會話中捕獲,並作爲javascript的一部分。

這是一個非常整潔的想法,我會說!