09-11-2011, 23:20
Witam,
Otóż do mojej strony postanowiłem dodać logowanie przez facebooka.
Skorzystałem z tego skryptu:
Chciałbym teraz dostać w zmiennej id użytkownika na facebooku.
Jak to osiągnąć?
Otóż do mojej strony postanowiłem dodać logowanie przez facebooka.
Skorzystałem z tego skryptu:
Kod PHP:
<html>
<head>
<title>My Facebook Login Page</title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID',
status : true,
cookie : true,
xfbml : true
});
FB.api('/me', function(user) {
if (user) {
var image = document.getElementById('image');
image.src = 'https://graph.facebook.com/' + user.id + '/picture';
var name = document.getElementById('name');
name.innerHTML = user.name
}
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div align="center">
<img id="image"/>
<div id="name"></div>
</div>
</body>
</html>
Jak to osiągnąć?