且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何检查用户是否在Facebook上分享我的链接

更新时间:2023-12-02 15:40:10

为此目的创建自定义按钮然后在javascript中使用registor click事件。在该事件中使用Fabebook API的FB.UI方法



https://developers.facebook.com/docs/sharing/reference/share-dialog [ ^ ]



Create your custom button for this purpose then registor click event in javascript. Inside that event use FB.UI method of Fabebook API

https://developers.facebook.com/docs/sharing/reference/share-dialog[^]


' #shareButton')。click(function(){
FB.ui({
方法:' share'
link:' samplelinktoshare'
caption:' 示例标题'
},函数(响应){
if (响应=== null ){
co nsole.log(' 未共享');
} 其他 {
// 成功分享,所以在这里写下你的下一个逻辑
}
});
});
('#shareButton').click(function() { FB.ui({ method: 'share', link: 'samplelinktoshare', caption: 'An example caption', }, function(response){ if (response === null) { console.log('was not shared'); } else { //Successfully shared, so write your next logic here } }); });