我们的服务允许任何公司为他们的业务进行促销。
用户设置一个促销,复制一段代码,并将其放在他们的网站上,该网站在iframe中显示促销。
推广页面嵌入了Facebook like按钮,当点击时,它将自动‘喜欢’该公司的facebook页面。
我们想要跟踪这些点击,并将它们显示在用户的仪表板中,这样他们就可以看到一次促销活动给他们带来了多少新的“赞”。
我们尝试使用FB.Event.subscribe,但单击like按钮时事件不会触发。我们对使用FB SDK非常陌生,所以我们可能遗漏了一些东西。下面是我们所拥有的:
window.fbAsyncInit = function() {
FB.init({
appId : '424426844274364', // App ID
channelUrl : '//www.viralsweep.com/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('edge.create',
function(response) {
alert('You FB liked the URL: ' + response);
}
);
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));发布于 2018-02-12 00:51:17
首先,您需要加载sdk.js
<script src ="https://connect.facebook.net/en_GB/sdk.js" ></script>然后调用该函数
FB.Event.subscribe('edge.create',
function(response) {
alert('You FB liked the URL: ' + response);
}
);现在,由于该函数是在sdk加载之前调用的,因此无法找到FB对象。
https://stackoverflow.com/questions/13372408
复制相似问题