我正在使用此代码来获取响应:
<fb:like layout="button_count" notify="true" colorscheme="dark" href="http://www.fbrell.com"></fb:like>
<script>
// this will fire when any of the like widgets are "liked" by the user
FB.Event.subscribe('edge.create', function(href, widget) {
alert('You liked ' + href, widget);
});
</script>
它没有给出任何回应。谁能说出我做错了什么?
答案 0 :(得分:1)
有关详细信息,请参阅https://developers.facebook.com/docs/reference/javascript/。
答案 1 :(得分:1)
假设你出现了FB Like按钮,所以你必须正确地包含SDK,我处于完全相同的情况 - 你所缺少的只是在fbAsyncInit()函数中设置订阅。
window.fbAsyncInit = function () {
FB.Event.subscribe('edge.create', function (targetUrl) {
_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);
});
};
如果您这样做,您不需要应用程序ID,也不需要使用FBML代码,您可以使用HTML5包含代码,如<div class='fb-like' data-href='...
答案 2 :(得分:0)
清单:
(我假设你已经设置了Javascript SDK)
在你的网址上运行FB linter,这里的错误可能会阻止它工作
http://developers.facebook.com/tools/debug
将此信息包含在页面顶部
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
如果您喜欢某个应用,请将其添加到您的应用页面
<meta property="fb:app_id" content="Your app id" />
喜欢按钮,将href更改为您的链接
<fb:like layout="button_count" show_faces="false" height="21" href="http://facebook.com"></fb:like>
如果它是一个应用程序,FB更喜欢HTTPS
function init() {
FB.init({
appId: APP_ID,
status: true,
cookie: true,
xfbml: true,
oauth: true
});
//uncomment if required
//window.fbAsyncInit = function() {
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
//}
}
init();