Skip to content

Instantly share code, notes, and snippets.

@gashtio
Created February 22, 2013 08:42
Show Gist options
  • Save gashtio/5011820 to your computer and use it in GitHub Desktop.
Save gashtio/5011820 to your computer and use it in GitHub Desktop.
Setting of portrait upon successful login in the Unity3D Facebook integration with Coherent UI sample
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.authResponse) {
// user has auth'd your app and is logged into Facebook
// request users' first name and profile picture
FB.api('/me?fields=picture,first_name', function(me){
SetPortrait(me);
userID = me.id;
});
}
})
function SetPortrait(fbAvatar) {
var url = fbAvatar.picture.data.url;
$('#fbButton').css("background-image", "url(" + url + ")"); // #fbButton is a <div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment