Created
February 22, 2013 08:42
-
-
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
This file contains 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
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