Skip to content

Instantly share code, notes, and snippets.

@julienrf
Created November 29, 2010 11:06
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save julienrf/719833 to your computer and use it in GitHub Desktop.
Save julienrf/719833 to your computer and use it in GitHub Desktop.
A small js snippet retrieving the feed of a Facebook page and displaying its elements.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="http://connect.facebook.net/fr_FR/all.js"></script>
<script>
// Replace the id by any other public page id
FB.api('170913076256527/feed', { limit: 3 }, function(result) {
$('#fb-feed').empty();
$(result.data).each(function(i, post) {
entry = $('<div class="fb-item"></div>');
if (post.icon) {
entry.append('<img class="icon" src="' + post.icon + '" />');
}
switch(post.type) {
case 'status':
entry.append('<div class="fb-content">' + post.message + ' (' + post.from.name + ')</div>');
break;
case 'link':
entry.append('<div class="fb-content">' + post.message + ' (' + post.from.name + ')</div>');
entry.append('<div class="fb-content"><a href="' + post.link + '">' + post.name + '</a></div>');
break;
case 'photo':
case 'video':
entry.append('<div class="fb-content"><a href="' + post.link + '">' + post.message + '</a> (' + post.from.name + ')</div>');
break;
}
$('#fb-feed').append(entry);
});
});
</script>
<div id="fb-feed">
Chargement de l’activité récente de la page Facebook…
</div>
@msasirekha
Copy link

hi

@foysalimran
Copy link

Seems it's not working.

@julienrf
Copy link
Author

Yeah, things may have changed in 12 years :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment