Search code examples
facebookfacebook-javascript-sdkfacebook-social-pluginsfacebook-sharer

How to customize shared information with Facebook Share methods


Im trying to share some content with the share dialog of facebook. My target is to share a product that a costumer bought. I like to share a custom text, an image of the product and the product link.

It should look like that:

MyImage

I know that Facebook scrapes the URL I pass and gets it information based on the page, but I really wish that I can pass the text at least to the share dialog.

So the question is how to customize the informations that are being shared.

I tried different solutions, like using the sharer.php link and with the FB SDK with share_button that uses FB.ui.

Sharer.php

<div class="fb-share-button" 
    data-href="http://www.facebook.com/sharer.php?s=100
    &p[url]=http://bit.ly/myelection&p[images][0]=http://election.gv.my/assets/vote.png
    &p[title]=My customized title
    &p[summary]=My customized summary"a-width="100">
</div>

Share-Button with JDK

<div class="fb-share-button" data-href="http://www.gartenxxl.de/p-1473049000">
</div>

I did not try to use the Javascript SDK and the FB.Ui method to create a share-dialog, because I did not want to register as Facebook-Developer yet and create an App for the FB-Api-Key, but maybe thats the only way. Then I would try that like this:

JS

$('#'#'#share_button').click(
    function(e){e.preventDefault();
         FB.ui(
         {
            method: 'feed',
            name: 'This is the content of the "name" field.',
            link: 'http://www.groupstudy.in/articlePost.php?id=A_111213073144',
            picture: 'http://www.groupstudy.in/img/logo3.jpeg',
            caption: 'Top 3 reasons why you should care about your finance',
            description: 'This is a Description',
            message: ''
        });
    });
});

Solution

  • Unfortunately, dynamic content is not really possible anymore:

    • The feed dialog is deprecated and should not be used anymore. Facebook will probably remove it sooner or later so i would not count on it.
    • Even if it would be possible to add a custom message with a parameter, it would not be allowed. According to the platform policy, the message must be 100% user generated, prefilling is not allowed.
    • All the existing (and NOT deprecated) possibilities only take the URL as parameter and they read the title/description/image from the Open Graph tags of that URL.

    The best you can do for bought products is to use the sharer.php, the Share Social Plugin or the FB.ui share dialog. If you want a custom share button design, you would need to go with sharer.php or FB.ui share, of course.

    Btw, this link may be helpful for the Open Graph tags: http://ogp.me/