Search code examples
facebookfacebook-javascript-sdkfacebook-sharerfacebook-share

customized facebook share button


I need to make a customized share button, where I can programmatically modify all the components of the share, such as the title, description, and sharing image.

I have tried just the og meta tags, but they haven't made a difference. I tried adding data-image etc. tags to the HTML link element, and that didn't fix it either. I also tried using the JS SDK, where I create a postToFeed() function with the data.

Am I doing something wrong? Are these outdated methods? Is this not the expected use case for the SDK share functions?


Solution

  • You need to refresh the Open Graph data for an URL in the debugger: https://developers.facebook.com/tools/debug/

    That tool is very important to test your OG tags too, of course.

    You can also use the feed dialog and specify your own data: https://developers.facebook.com/docs/sharing/reference/feed-dialog/

    Although, i would recommend using OG tags with the share dialog.