Drazxier Drazxier - 2 months ago 23
Javascript Question

Facebook Social Button plugin

So I've been trying for some time to integrate this plugin provided by facebook at Facebook-Social-Button-Plugin

and there it has even mentioned to copy/paste the given code, to see it in action :-

<html>
<head>
<title>Your Website Title</title>
<!-- You can use Open Graph tags to customize link previews.
Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
<meta property="og:url" content="http://www.your-domain.com/your-page.html" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Your Website Title" />
<meta property="og:description" content="Your description" />
<meta property="og:image" content="http://www.your-domain.com/path/image.jpg" />
</head>
<body>

<!-- Load Facebook SDK for JavaScript -->
<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";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<!-- Your share button code -->
<div class="fb-share-button"
data-href="http://www.your-domain.com/your-page.html"
data-layout="button_count">
</div>

</body>
</html>





But it isn't showing anything in the page
So am I missing something or is there any problem with this plugin, like I need to get it in a running web server and not in some localhost or it has to do with creating app in fb to use this feature, since none of this mentioned in their documentation.




And yeah I've tried putting correct meta properties and data-href in accordance to my localhost as I am building my web app in laravel framework.

Answer

Tried the code and I get the error VM114 sdk.js:99 Uncaught Error: invalid version specified seems to be an error on their code or the example wasn't meant to be copy and pasted, however if you generate the code by clicking the get code button you will get a slightly different code that contains a different url with your appID and version looks something like this:

 connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.7&appId=XXXXXXXXXX

that seems to work

Comments