Skip to content

Instantly share code, notes, and snippets.

@pwim
Created May 21, 2011 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwim/984510 to your computer and use it in GitHub Desktop.
Save pwim/984510 to your computer and use it in GitHub Desktop.
Facebook Graph API
# javascript
$(function() {
var ids = $('//[data-fb-id]').map(function(){
return $(this).data("fb-id");
})
$.unique(ids).each(function(){
FB.api('/' + this, function(r){
$("//[data-fb-id='"+ r["id"] + "']").each(function(){
var attr = $(this).data("fb-attr");
$(this).text(r[attr]);
});
})
});
});
# html
<span data-fb-attr="name" data-fb-id="582880416"></span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment