admin管理员组文章数量:1328034
I'm trying to subscribe to the "edge.create" event in conjunction with new Facebook Share button without any luck. I'm using the standard event subscription:
FB.Event.subscribe('edge.create',
function(response) {
console.log(response);
}
);
The event is not fired... It works instead with the Like button
Any suggestion?
I'm trying to subscribe to the "edge.create" event in conjunction with new Facebook Share button without any luck. I'm using the standard event subscription:
FB.Event.subscribe('edge.create',
function(response) {
console.log(response);
}
);
The event is not fired... It works instead with the Like button
Any suggestion?
Share Improve this question asked Dec 1, 2013 at 14:06 Gabriele PeregoGabriele Perego 1132 gold badges2 silver badges7 bronze badges2 Answers
Reset to default 4The facebook share button has been deprecated in favor of the like button. From their docs:
The Share button has been deprecated in favor of the Like button, and will no longer be supported. Please use the Like button whenever possible to drive maximum traffic to your apps.
You can use the event with the like button, however if you want to track the shared button then it is still possible with some javascript. You can add a click event to your FB share button.
Here is an example I'm using.
window.fbAsyncInit = function () {
FB.init({
appId: 'your app id',
status: true,
cookie: true,
xfbml: true,
oauth: true
});
$('#facebook-share').click(function () {
FB.ui({
method: 'feed',
link: document.URL,
caption: 'example',
}, function (response) {
if (response === null) {
console.log('post was not shared');
} else {
console.log('post was shared');
}
});
});
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.async = true;
js.src = "//connect.facebook/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Create a facebook app and get approved are boring and can take so much time...
An alternative way I made here to who don't want to publish an APP just for it is:
jQuery("#div_share").click(function() {
var url = "http://www.facebook./sharer/sharer.php?u=YOUR_URL&title=YOUR_TITLE";
var openDialog = function(uri, name, options, closeCallback) {
var win = window.open(uri, name, options);
var interval = window.setInterval(function() {
try {
if (win == null || win.closed) {
window.clearInterval(interval);
closeCallback(win);
}
}
catch (e) {
}
}, 1000);
return win;
};
openDialog(url,'Facebook','width=640,height=580', function(){
jQuery("#div_share").hide();
jQuery("#formulario").show();
});
});
It will open a javascript dialog to share, and know when the user close it. It's not guaranteed that they really share the content... but.. :)
本文标签: javascriptCallback function with new Facebook Share buttonStack Overflow
版权声明:本文标题:javascript - Callback function with new Facebook Share button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742238306a2438481.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论