Skip to content

Instantly share code, notes, and snippets.

@mojowen
Created August 21, 2012 00:51
Show Gist options
  • Save mojowen/3410080 to your computer and use it in GitHub Desktop.
Save mojowen/3410080 to your computer and use it in GitHub Desktop.
Facebook / Tumblr / Twitter link-to-share configurations
var img = '', // Le image you're linking to
link = '', // Le page you're linkg to
message = '' // Le message you want to share ( Twitter / Tumblr only )
/**
NOTE: More customization can be done fore facebook whatever page 'link' is point out on, see https://developers.facebook.com/tools/debug on how to ge this working using OG tags
**/
var facebook = 'http://facebook.com/sharer/sharer.php?u='+escape( link );
//twitter specific vars - via/referr twitter names / hash tag phrases to hashtag.
// Can also use hashtags in message but need to encode them
var referr = '', via = '', hashtags = ''
var twitter = 'https://twitter.com/intent/tweet?original_referer='+referr+
'&source=tweetbutton&hashtags='+hashtags+
'&via='+via+
'&text='+message+
'&url='+link.replace(/ /g,'-').replace(/\&/g,'%26');
// This is for sharing an image on tumblr
var tumblr = 'http://www.tumblr.com/share/photo?source='+escape(img)+
'&caption='+escape( message )+
'&click_thru='+escape(link);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment