Return to Snippet

Revision: 31482
at September 7, 2010 17:53 by marvinsum


Initial Code
<div id="fb-root"></div> 
  <script src="http://connect.facebook.net/en_US/all.js"></script> 
  <script type="text/javascript"> 
    FB.init({appId : '150545208302203', status : true, cookie : true});
    $(document).ready(function() {
  	  $('#facebook').bind('click', function() {
  			FB.login(function(login_response){
  				FB.api(
  				  {
  				    method: 'fql.query',
  				    query: 'SELECT first_name, last_name, sex, pic_big, birthday_date, email FROM user WHERE uid = ' + FB.getSession().uid
  				  },
  				  function(response) {
  		        var user = response[0];
  			      document.getElementById('UserFbId').value = FB.getSession().uid;
  			      document.getElementById('UserEmail').value = user.email;
  		        if(user.birthday_date != null) {
  		          user.birthday_date = user.birthday_date.split("/");
  		          if(user.birthday_date.length > 0) document.getElementById('UserDobMonth').value = user.birthday_date[0];
    			      if(user.birthday_date.length > 1) document.getElementById('UserDobDay').value = user.birthday_date[1];
    			      if(user.birthday_date.length > 2) document.getElementById('UserDobYear').value = user.birthday_date[2];
  			      }
  			      document.getElementById('UserName').value = user.first_name + ' ' + user.last_name;
  			      document.getElementById('UserFbThumbnail').value = user.pic_big;
  			      if(user.sex == 'male') {
  				      document.getElementById('UserGender').value = 'M';
  			      }
  			      else if(user.sex == 'female') {
  			        document.getElementById('UserGender').value = 'F';
  			      }
  			      document.getElementById('UserAddForm').submit();
  				  }
  				);
  			}, {perms:'publish_stream,email,user_birthday'});
    	});
  	});
  </script>

Initial URL

                                

Initial Description

                                

Initial Title
Get FB User data via FQL

Initial Tags

                                

Initial Language
Java