Custom sharing Buttons

108 views Asked by At

I am trying to implement social media sharing buttons on my Website. I am successfull in implementing the facebook sharing button.

My Code :

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Now i can see the share button and i am able to share the required page. When i click the button another modal comes up :enter image description here

Now i want when a user clicks the share button then a pre defined message should be there in the highlighted area. How can i acheive this here and also in LinkedIn, Twitter and Google+ buttons.

Do i have to use Open Graph Protocol for this? If yes then can anybody post an article regarding this or tell me how can i achieve this using OG.

2

There are 2 answers

3
Dhruv Kapatel On

For facebook : open graph will fetch og tags for description from that link to display description in share popup.

you can set title,description,thumbnail using meta tag like this.

<meta property="og:title" content="title" />
<meta property="og:description" content="description" />
<meta property="og:image" content="thumbnail_image" />

For twitter: Go through this link see data-text.

https://dev.twitter.com/web/tweet-button/parameters

2
andyrandy On

Prefilling the message is not allowed on Facebook, and it´s not possible anyway. You may want to read the platform policy.