Created
November 29, 2010 11:06
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
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
Seems it's not working.