21

Facebook introduced embedded posts (https://developers.facebook.com/docs/plugins/embedded-posts/), but it only lets me embed a given post onto my webpage.

I would like to automatically embed the newest Facebook post from our company Facebook profile into our webpage. Is that possible?

Pikamander2
  • 7,332
  • 3
  • 48
  • 69
Pascal Klein
  • 23,665
  • 24
  • 82
  • 119

4 Answers4

12

Is this what you're looking for?

<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2FYOUR-FB-PAGE-ID&width=600&colorscheme=light&show_faces=true&border_color&stream=true&header=true&height=435" scrolling="yes" style="border:none; overflow:hidden; width:600px; height:430px; background: white; float:left; " allowtransparency="true" frameborder="0"></iframe>

Replace YOUR-FB-PAGE-ID with the Facebook page's ID.

JSFiddle example

Source: https://www.youtube.com/watch?v=vmFShEeI5qg

Pikamander2
  • 7,332
  • 3
  • 48
  • 69
4

The solution above suggested this, but you can always get a Page Access Token (you need a user access token from a user who is an admin of that page before requesting the page access token) and request access to that page's feed so that you can get the latest post ID and embed that post with the ID.

Page access tokens: https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens

jake2389
  • 1,166
  • 8
  • 22
  • Have you tried to read that page on access tokens? If you already figured out how to get an access token, I'm sure it makes sense. If you don't have any access token of any kind, it makes absolutely no sense at all. I've been through this many times (because they keep changing the interface) and it is far more difficult to get a token than it is to write an app. – kainaw Nov 15 '17 at 18:16
  • 1
    I found [this thread](http://stackoverflow.com/questions/17197970/facebook-permanent-page-access-token) very useful regarding getting a permanent token. – Marc Nov 20 '17 at 10:40
2

2 ways:

1) Javascript

Step 1: Include the JavaScript SDK on your page once, ideally right after the opening body tag.

<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/sdk.js#xfbml=1&version=v3.1';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Step 2: Place this code wherever you want the plugin to appear on your page.

<div class="fb-page" data-href="https://www.facebook.com/google" data-tabs="timeline" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true"><blockquote cite="https://www.facebook.com/google" class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/google">Google</a></blockquote></div>

2) iframe

Place this code wherever you want the plugin to appear on your page.

<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Fgoogle&tabs=timeline&width=340&height=500&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId" width="340" height="500" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>

Source: Facebook

The Page plugin lets you easily embed and promote any public Facebook Page on your website. Just like on Facebook, your visitors can like and share the Page without leaving your site. You can use the Page plugin for any Page that is not restricted, for example, by country or age.

https://developers.facebook.com/docs/plugins/page-plugin/

TommyZG
  • 500
  • 3
  • 13
1

You can do it with Graph API https://developers.facebook.com/docs/graph-api/reference/v2.8/page/feed

Or oEmbed https://developers.facebook.com/docs/plugins/oembed-endpoints

Kaspar L. Palgi
  • 1,332
  • 10
  • 22
  • 3
    Your suggestion only works once you have an access token. Anyone wishing to implement this needs to find someone who knows how to get an access token before considering trying to use the API. – kainaw Nov 15 '17 at 18:17