Share and add a custom message?

362 views Asked by At

I've integrated a Facebook share button into my site. The client now wishes to add a prepopulated message when a user presses the share button, so this can be written to the users timeline. (If they agree).

I've checked out the share button on facebook:

https://developers.facebook.com/docs/plugins/share-button/

But I cant find anywhere how to add a custom message to the share button?

2

There are 2 answers

0
Aaron On BEST ANSWER

You'll need to add facebooks OG tags to the head of your page, Facebook will read these and add the content. You can add a custom title, image and description.

<meta property="og:title" content="title" />
<meta property="og:description" content="description" />
<meta property="og:image" content="http://www.website.com/thumbnail" />

If you need to add a custom title, image or description per page then you'll need to use a php constant to define these on a per-page basis.

With something like:

<?php 
$title = 'Title Here';
$desc = 'Description goes here...';
?>

Then the meta tags would look like this.

<meta property="og:title" content="<?php echo $title ?>" />
<meta property="og:description" content="<?php echo $desc ?>" />
<meta property="og:image" content="http://www.website.com/thumbnail" />

Check out the docs here:

0
andyrandy On

According to the platform policy, you are not allowed to prefill the message:

2.3: Don't prefill captions, comments, messages, or the user message parameter of posts with content a person didn’t create, even if the person can edit or remove the content before sharing

...and it´s not possible with the Share Plugin anyway. The message must be 100% user generated and there is no possible way to implement this.