Skip to content

Instantly share code, notes, and snippets.

@guicheffer
Last active June 7, 2016 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guicheffer/e030a05ba2a7d017886c to your computer and use it in GitHub Desktop.
Save guicheffer/e030a05ba2a7d017886c to your computer and use it in GitHub Desktop.
social media (share) functions
function shareFacebook(title, summary, url, image) {
url = ['https://www.facebook.com/sharer/sharer.php?s=100&p[summary]=', encodeURI(summary), '&p[title]=', encodeURI(title), '&p[url]=', encodeURI(url), '&p[images][0]=', encodeURI(image)];
window.open(url.join(''), 'facebook', 'height=300,width=600');
}
function shareFacebookFBui(options, callbackShare) {
// http://developers.facebook.com/docs/reference/dialogs/feed/
var defaults = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs'
};
/* merge defaults and options, without modifying defaults */
var obj = $.extend({}, defaults, options);
FB.ui(obj, callbackShare);
}
function shareTwitter (text, url) {
url = ['http://twitter.com/share?text=', encodeURI(text), '&url=', encodeURI(url)];
window.open(url.join(''), 'twitter', 'height=300,width=600');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment