我正在尝试检测我网站上的用户是否成功将内容分享到他们的Facebook页面上。我正在关注facebook sdk的文档和一些教程,并提出了这个
<html>
<head>
</head>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script>
<script src="//connect.facebook.net/en_US/sdk.js"></script>
<button class='share-btn'>click</button>
<script>
function fb_share() {
FB.init({
appId : 'snip',
xfbml : true,
version : 'v2.8'
});
FB.ui( {
method: 'share',
name: "Facebook API: Tracking Shares using the JavaScript SDK",
href: "https://test.com",
picture: "http://test.com",
caption: "Tracking Facebook Shares on your website or application is a useful way of seeing how popular your articles are with your readers. In order to tracking Shares, you must used the Facebook JavaScript SDK."
}, function( response ) {
if ( response !== null) {
console.log( response );
// ajax call to save response
}
} );
}
$(document).ready(function(){
$('.share-btn').on( 'click', fb_share );
});
</script>
</body>
</html>
当我在控制台中看到响应时...它只是说undefined
。
有谁能告诉我他们是如何完成这件事的?