Skip to content

Instantly share code, notes, and snippets.

@maxcal
Created September 12, 2011 09:18
Show Gist options
  • Save maxcal/1210897 to your computer and use it in GitHub Desktop.
Save maxcal/1210897 to your computer and use it in GitHub Desktop.
fb_ui_dialog.js
/* * * * * * * * * * * * * * * * * * * * * * *
* Custom facebook share dialog
* Requires FB SDK & jQuery
* UNTESTED! Use with caution!
* * * * * * * * * * * * * * * * * * * * * * * */
// @ doc ready
jQuery(document).ready(function($){
// When user clicks #my_fb_share_button
// TODO: Replace #my_fb_share_button with your own selector
$("#my_fb_share_button").click( function(e){
// Open up a Facebook share dialog.
// @ see - http://developers.facebook.com/docs/reference/javascript/FB.ui/
FB.ui(
// @ params
// TODO: customize this
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
// @ callback (do this when user interacts with dialog).
function(response) {
// Do if user shares
if (response && response.post_id) {
// TODO: Do something meaningfull here / or nothing
alert('Thank you for sharing');
} else {
// TODO: Do something meaningfull here / or nothing
alert('Post was not published.');
}
}
);
// Prevent defualt browser action
return false;
});
//@ End doc ready
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment