4
下面是我在我的網站上使用Facebook Like按鈕(和Share按鈕)的代碼。去哪裏放置FB.Event.subscribe
它很好用。我點擊了Like按鈕,並且繁榮,我的Facebook帳戶的個人資料頁面中有一個很好的通知。 Facebook甚至會自動生成一個恰好是我網站標識的預覽圖像。精彩。我網站上的Like計數器正確計算。
所以我想記錄點擊Like按鈕。根據this頁面,代碼FB.Event.subscribe('edge.create', function(response) {});
可以讓你做到這一點。
在下面的代碼中,我應該把代碼FB.Event.subscribe('edge.create', function(response) {});
?
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<?php
echo '<div id="fb-root"></div>';
echo "<script type='text/javascript'>
window.fbAsyncInit = function() {
FB.init({appId: 'my_fb_app_id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
});
</script>";
echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="" send="true" layout="button_count" width="450" show_faces="false" font="arial"></fb:like>';
?>
沒錯:在初始化後立即放置所有事件訂閱通常是最容易的。這樣你就不會錯過任何東西。 – Femi