0

I am trying to display a Facebook "like" button on a web page. In order to do so, I decided to follow the official guide here.

First I decided to dump the suggested code into a local HTML file and look at it using my browser:

<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 = "https://connect.facebook.net/en_US/all.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    <!-- Your like button code -->
    <div class="fb-like" 
        data-href="https://developers.facebook.com/docs/plugins/" 
        data-layout="standard" 
        data-action="like" 
        data-show-faces="true">
    </div>

</body>
</html>

After it didn't work, I looked on SO and found this answer and realized that the HTML has to be served by a web server, and the js.src needs to be updated to https://connect.facebook.net/en_US/all.js

However, after doing that, I still only see a completely blank page when I try to look at the page with chrome on mac.

If I inspect the page source I can see my source code, but I see no visuals whatsoever.

What gives?

Community
  • 1
  • 1
ForeverStudent
  • 2,487
  • 1
  • 14
  • 33

1 Answers1

1

I recently went through this same process and could not figure out why it was not working. Turns out it was working FaceBook had simply not updated yet. You can force it to update here:

https://developers.facebook.com/tools/debug/

Enter your URL and press: Scrape Again. See if that helps.

AndrewLeonardi
  • 3,351
  • 9
  • 47
  • 100