I'd like new users to be able to 'connect' with the use of the fb connect button on my site and once connected it will display their first+last name and profile picture.
If the user is already connected, the connect button turns into a logout.
Going by the docs, i've implemented the following code;
<html>
<head>
<title>test full name and photo</title>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:'xxxxxxxxxx', cookie:true,
status:true, xfbml:true
});
FB.api('/me', function(user) {
if(user != null) {
var image = document.getElementById('image');
image.src = 'http://graph.facebook.com/' + user.id + '/picture';
var name = document.getElementById('name');
name.innerHTML = user.name
}
});
</script>
<div align="center">
<img id="image"/>
<div id="name"></div>
</div>
</body>
</html>
The only problem is that it does not display the facebook connect button and when I try and insert it, the code breaks.
Any help would be much appreciated!
recap: website checks if the user has connected and has a valid session, if not, display fb connect/login button, if yes, display the logout button, either way it should show the user their name and profile photo.
Thank you!