Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Last active February 8, 2019 09:49
Show Gist options
  • Save niraj-shah/5560832 to your computer and use it in GitHub Desktop.
Save niraj-shah/5560832 to your computer and use it in GitHub Desktop.
Facebook Feed Callback
function fb_share() {
FB.ui( {
method: 'feed',
name: "Facebook API: Tracking Shares using the JavaScript SDK",
link: "https://www.webniraj.com/2013/05/11/facebook-api-tracking-shares-using-the-javascript-sdk/",
picture: "https://stackexchange.com/users/flair/557969.png",
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 ) {
console.log( response );
if ( response !== null && typeof response !== 'undefined' && typeof response.post_id !== 'undefined' ) {
// ajax call to save response
$.post( 'http://www.webniraj.com/', { 'meta': response }, function( result ) {
console.log( result );
}, 'json' );
}
} );
}
$(document).ready(function(){
$('button.share-btn').on( 'click', fb_share );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment